
********************************************************************************
********************************************************************************
********************************************************************************
******************************** DATA APPENDING ********************************
********************************************************************************
********************************************************************************
********************************************************************************

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "ns20201008.dta", clear
append using "ns20201224.dta"
append using "ns20210112.dta"
append using "ns20201203.dta"
append using "ns20201210.dta"
append using "ns20201217.dta"
append using "ns20201112.dta"
append using "ns20201119.dta"
append using "ns20201126.dta"
append using "ns20201022.dta"
append using "ns20201029.dta"
append using "ns20201105.dta"
append using "ns20201001.dta"
append using "ns20201015.dta"
append using "ns20200910.dta"
append using "ns20200917.dta"
append using "ns20200924.dta"
append using "ns20200827.dta"
append using "ns20200903.dta"
append using "ns20200806.dta"
append using "ns20200813.dta"
append using "ns20200820.dta"
append using "ns20200716.dta"
append using "ns20200723.dta"
append using "ns20200730.dta"
append using "ns20200625.dta"
append using "ns20200702.dta"
append using "ns20200709.dta"
append using "ns20200604.dta"
append using "ns20200611.dta"
append using "ns20200618.dta"
append using "ns20200514.dta"
append using "ns20200521.dta"
append using "ns20200528.dta"
append using "ns20200430.dta"
append using "ns20200507.dta"
append using "ns20200409.dta"
append using "ns20200416.dta"
append using "ns20200423.dta"
append using "ns20200326.dta"
append using "ns20200402.dta"
append using "ns20200305.dta"
append using "ns20200312.dta"
append using "ns20200319.dta"
append using "ns20200206.dta"
append using "ns20200213.dta"
append using "ns20200220.dta"
append using "ns20200227.dta"
append using "ns20200116.dta"
append using "ns20200123.dta"
append using "ns20200130.dta"
append using "ns20191226.dta"
append using "ns20200102.dta"
append using "ns20200109.dta"
append using "ns20191205.dta"
append using "ns20191212.dta"
append using "ns20191219.dta"
append using "ns20191114.dta"
append using "ns20191121.dta"
append using "ns20191128.dta"
append using "ns20191031.dta"
append using "ns20191107.dta"
append using "ns20191010.dta"
append using "ns20191017.dta"
append using "ns20191024.dta"
append using "ns20190905.dta"
append using "ns20190912.dta"
append using "ns20190919.dta"
append using "ns20190926.dta"
append using "ns20191003.dta"
append using "ns20190808.dta"
append using "ns20190815.dta"
append using "ns20190822.dta"
append using "ns20190829.dta"
append using "ns20190718.dta"
append using "ns20190725.dta"
append using "ns20190801.dta"

save "nsALL.dta", replace

********************************************************************************
********************************************************************************
********************************************************************************
******************************** DATA CLEANING *********************************
********************************************************************************
********************************************************************************
********************************************************************************

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALL.dta", clear

sort start_date

generate start_datetr = string(start_date, "%tc")
gen start_daytr=substr(start_datetr, 1, 9)
generate start_day_num=date(start_daytr,"DMY") 
gen start_day_month=substr(start_datetr, 3, 3)
gen start_day_year=substr(start_datetr, 6, 4)

tab start_day_num if start_daytr=="08mar2020"
gen running_dst_2020=start_day_num-21982 

gen interest_flipped=4 if interest==1
replace interest_flipped=3 if interest==2
replace interest_flipped=2 if interest==3
replace interest_flipped=1 if interest==4

gen intend_vote=1 if vote_intention==1
replace intend_vote=0 if vote_intention==2 | vote_intention==999 // like the CPS


replace ideo5=. if ideo5>5

foreach var in group_favorability_muslims discrimination_muslims muslimban {
	
	replace `var'=. if `var'==999
	
}

foreach var in group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_republicans group_favorability_democrats group_favorability_white_men group_favorability_jews group_favorability_blm  discrimination_blacks discrimination_whites discrimination_muslims discrimination_christians discrimination_jews discrimination_women discrimination_men wall cap_carbon guns_bg mctaxes estate_tax raise_upper_tax college abortion_never abortion_conditions late_term_abortion gov_insurance public_option health_subsidies path_to_citizenship dreamers deportation ban_guns ban_assault_rifles limit_magazines {
	
	replace `var'=. if `var'==999
	
}

foreach var in cand_favorability_trump cand_favorability_biden  {
	
	replace `var'=. if `var'==999
	
}

sum ideo cand_favorability_trump cand_favorability_biden  group_favorability_republicans group_favorability_democrats group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_whites group_favorability_white_men group_favorability_jews group_favorability_blm 

gen other_race=1 if race_ethnicity==3 | race_ethnicity==15
replace other_race=0 if race_ethnicity~=3 & race_ethnicity~=15

gen aapi_race=1 if race_ethnicity>=4 & race_ethnicity<=14
replace aapi_race=0 if race_ethnicity==1 | race_ethnicity==2 | race_ethnicity==3 | race_ethnicity==15

rename ideo conservatisim

foreach var in conservatisim cand_favorability_trump cand_favorability_biden group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews group_favorability_blm   group_favorability_republicans group_favorability_democrats  {
tab `var'
}

foreach var in conservatisim cand_favorability_trump cand_favorability_biden group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews group_favorability_blm   group_favorability_republicans group_favorability_democrats  {

egen s`var'=std(`var'), mean(0) std(1)

}

foreach var in conservatisim cand_favorability_trump cand_favorability_biden group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews group_favorability_blm   group_favorability_republicans group_favorability_democrats  {

sum s`var'

}

recode racial_attitudes_generations (1=5) (2=4) (3=3) (4=2) (5=1)
recode racial_attitudes_date (1=5) (2=4) (3=3) (4=2) (5=1)

factor racial_attitudes_tryhard racial_attitudes_generations racial_attitudes_marry racial_attitudes_date 
predict racial_resentment

recode gender_attitudes_maleboss (1=5) (2=4) (3=3) (4=2) (5=1)
recode gender_attitudes_complain (1=5) (2=4) (3=3) (4=2) (5=1)

factor gender_attitudes_maleboss gender_attitudes_logical gender_attitudes_opportunity gender_attitudes_complain
predict gender_resentment

egen sracial_resentment=std(racial_resentment), mean(0) std(1)
egen sgender_resentment=std(gender_resentment), mean(0) std(1)

foreach var in wall cap_carbon guns_bg mctaxes estate_tax raise_upper_tax college abortion_never  late_term_abortion gov_insurance public_option health_subsidies path_to_citizenship dreamers deportation ban_guns ban_assault_rifles limit_magazines {
	
	replace `var'=0 if `var'==2 
	
}

foreach var in wall cap_carbon guns_bg estate_tax raise_upper_tax college abortion_never  late_term_abortion gov_insurance public_option health_subsidies path_to_citizenship dreamers deportation ban_guns ban_assault_rifles limit_magazines {
	
	gen c_`var'=`var'
	
}

recode c_cap_carbon (1=0) (0=1)
recode c_guns_bg (1=0) (0=1)
recode c_raise_upper_tax (1=0) (0=1)
recode c_college (1=0) (0=1)
recode c_late_term_abortion (1=0) (0=1)
recode c_gov_insurance (1=0) (0=1)
recode c_public_option (1=0) (0=1)
recode c_health_subsidies (1=0) (0=1)
recode c_path_to_citizenship (1=0) (0=1)
recode c_dreamers (1=0) (0=1)
recode c_ban_guns (1=0) (0=1)
recode c_ban_assault_rifles (1=0) (0=1)
recode c_limit_magazines (1=0) (0=1)

factor c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines
predict conservative_policy
egen sconservative_policy=std(conservative_policy), mean(0) std(1)

corr conservative_policy conservatisim // r=0.556; Cohen says 0.5 is large
regress sconservative_policy sconservatisim // b=0.5008 - 1 std. shift in self-reported conservatisism predicts 0.5 sds higher; large effect

regress racial_resentment i.pid3
regress gender_resentment i.pid3

*Dimensions of political views
factor conservative_policy conservatisim scand_favorability_trump scand_favorability_biden  c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sgroup_favorability_democrats sgroup_favorability_republicans // different dimensions, so makes sense to look individually

*Dimensions of others views
factor racial_resentment gender_resentment  group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews // different dimensions, so makes sense to look individually

factor c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sconservative_policy sconservatisim scand_favorability_trump scand_favorability_biden  sgroup_favorability_democrats sgroup_favorability_republicans sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews, blanks(0.4)

save "nsALLCLEAN.dta", replace

*DVs for heatmap
keep c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sconservative_policy sconservatisim scand_favorability_trump scand_favorability_biden  sgroup_favorability_democrats sgroup_favorability_republicans sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews

foreach v in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sconservative_policy sconservatisim scand_favorability_trump scand_favorability_biden  sgroup_favorability_democrats sgroup_favorability_republicans sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews { 
	drop if missing(`v') 
}

saveold "nsALLCLEANDVS.dta", version(12) replace

********************************************************************************
********************************************************************************
********************************************************************************
******************************** RESULTS ***************************************
********************************************************************************
********************************************************************************
********************************************************************************

***** Ideology- Conservatism
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

rdrobust sconservatisim running_dst_2020, all vce(cluster running_dst_2020) // all 
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism.dta", detail(all) addlabel(Group, All) replace

rdrobust sconservatisim running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism.dta", detail(all) addlabel(Group, Democrats) append

rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism.dta", detail(all) addlabel(Group, Republicans) append

rdrobust sconservatisim running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism.dta", detail(all) addlabel(Group, Independents) append

rdrobust sconservatisim running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism.dta", detail(all) addlabel(Group, Other Party) append

*Rd plot
rdplot sconservatisim running_dst_2020, all vce(cluster running_dst_2020) ci(95)  // all
gr_edit .plotregion1.plot2.style.editstyle marker(symbol(circle)) editcopy
gr_edit .plotregion1.plot2.style.editstyle marker(fillcolor(%60)) editcopy
gr_edit .plotregion1.plot2.style.editstyle marker(linestyle(color(%60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(%60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle marker(size(zero)) editcopy
gr_edit .plotregion1.plot2.style.editstyle marker(linestyle(color(none))) editcopy
gr_edit .title.draw_view.setstyle, style(no)
gr_edit .yaxis1.reset_rule -1 1 0.2 , tickset(major) ruletype(range) 
gr_edit .plotregion1.plot3.style.editstyle line(color(black)) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(width(medium)) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(width(thick)) editcopy
gr_edit .plotregion1.plot4.style.editstyle line(width(thick)) editcopy
gr_edit .plotregion1.plot4.style.editstyle line(color(black)) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(pattern(dash)) editcopy
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Days Since Start of Daylight Savings
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Conservatism (Standardized)

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism_all.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism_all.pdf", as(pdf) name("Graph") replace

	*Mention: robustness of conservative effect among Rs to polynomials BWs
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) p(1) q(2) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) p(2) q(3) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) p(3) q(4) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) p(4) q(5) // Republicans

	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(20) b(20) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(30) b(30) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(40) b(40) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(50) b(50) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(60) b(60) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(70) b(70) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(80) b(80) // Republicans
	rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(90) b(90) // Republicans

*Clean the data for figure generating
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism.dta", clear	

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism_clean.dta", replace	version(12)
	
*Table generating

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservatism.dta", clear

order Group 
drop var level cmd depvar runningvar outcomevar clustvar vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figure3.tex, replace

	
	
****** Conservarive Policy Positions - 0/1
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

	rdrobust sconservative_policy running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	

foreach var in  c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	*all
	rdrobust `var' running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
}

*clean data
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy.dta"

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", version(12) replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear
keep if Group=="All"

drop if DV=="sconservative_policy"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean_all.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear

keep if Group=="All"
drop if DV=="sconservative_policy"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV


replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

order  DV

texsave * using figureS3a.tex, replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear
keep if Group=="Democrats"
drop if DV=="sconservative_policy"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean_democrats.dta", version(12) replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear

keep if Group=="Democrats"
drop if DV=="sconservative_policy"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV


replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

order  DV

texsave * using figureS2a.tex, replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear
keep if Group=="Republicans"
drop if DV=="sconservative_policy"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean_republicans.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear

keep if Group=="Republicans"
drop if DV=="sconservative_policy"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV


replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

order  DV

texsave * using figureS2b.tex, replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear
keep if Group=="Independents"
drop if DV=="sconservative_policy"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean_independents.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear

keep if Group=="Independents"
drop if DV=="sconservative_policy"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV


replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

order  DV

texsave * using figureS3b.tex, replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean.dta", clear
keep if Group=="Other Party"
drop if DV=="sconservative_policy"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"
replace DV="Conservative Policy" if DV=="sconservative_policy"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/conservative_policy_clean_others.dta", version(12) replace

****** Incumbent v. Challenger Favorability
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

	*all
	rdrobust scand_favorability_trump running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, All, DV, scand_favorability_trump) replace
	*Democrats
	rdrobust scand_favorability_trump running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Democrats, DV, scand_favorability_trump) append
	*Republicans
	rdrobust scand_favorability_trump running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Republicans, DV, scand_favorability_trump) append
	*Independents
	rdrobust scand_favorability_trump running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Independents, DV, scand_favorability_trump) append
	*Other
	rdrobust scand_favorability_trump running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Other Party, DV, scand_favorability_trump) append

foreach var in  cand_favorability_biden   {
	
	*all
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, All, DV, s`var') append
	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
}

*Data Cleaning
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", clear

keep if DV=="scand_favorability_trump"

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

replace DV="Incumbent Presidential Approval"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_clean.dta", version(12) replace



*Table generating, 4a

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", clear

keep if DV=="scand_favorability_trump"

order Group 
drop var level cmd depvar runningvar outcomevar clustvar vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r DV


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figure4a.tex, replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", clear

keep if DV=="scand_favorability_biden"

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

replace DV="Challenger Presidential Approval"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/challenger_clean.dta", version(12) replace

*Table generating, 4b

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/incumbent_challenger.dta", clear

keep if DV=="scand_favorability_biden"

order Group 
drop var level cmd depvar runningvar outcomevar clustvar vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r DV


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figure4b.tex, replace

********** Racial/Gender resentment
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

	*all
	rdrobust sracial_resentment running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, All, DV, sracial_resentment) replace
	*Democrats
	rdrobust sracial_resentment running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Democrats, DV, sracial_resentment) append
	*Republicans
	rdrobust sracial_resentment running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Republicans, DV, sracial_resentment) append
	*Independents
	rdrobust sracial_resentment running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Independents, DV, sracial_resentment) append
	*Other
	rdrobust sracial_resentment running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Other Party, DV, sracial_resentment) append

foreach var in  gender_resentment   {
	
	*all
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, All, DV, s`var') append
	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
}

*Data Cleaning
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", clear

keep if DV=="sracial_resentment"

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

replace DV="Racial Resentment"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_resentment.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", clear

keep if DV=="sracial_resentment"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar DV


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order  Group

texsave * using figureS7a.tex, replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", clear

keep if DV=="sgender_resentment"

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

replace DV="Gender Resentment"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/gender_resentment.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/racial_gender_resentment.dta", clear

keep if DV=="sgender_resentment"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar DV


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order  Group

texsave * using figureS7b.tex, replace


************* Attitudes towards various minority and majority groups 
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

	*all
	rdrobust sgroup_favorability_whites running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, All, DV, sgroup_favorability_whites) replace

	*Democrats
	rdrobust sgroup_favorability_whites running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Democrats, DV, sgroup_favorability_whites) append

	*Republicans
	rdrobust sgroup_favorability_whites running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Republicans, DV, sgroup_favorability_whites) append

	*Independents
	rdrobust sgroup_favorability_whites running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Independents, DV, sgroup_favorability_whites) append

	*Other
	rdrobust sgroup_favorability_whites running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Other Party, DV, sgroup_favorability_whites) append

foreach var in  group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews   {

	*all
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append

	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append

	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Independents, DV, s`var') append

	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append

	}
	
*Data Cleaning

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups.dta", clear
	
gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", version(12) replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear
keep if Group=="All"

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"


saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_all.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear

keep if Group=="All"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"

order  DV

texsave * using figureS5a.tex, replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear
keep if Group=="Republicans"

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="BLM" if DV=="sgroup_favorability_blm"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_republicans.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear

keep if Group=="Republicans"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"

order  DV

texsave * using figureS4b.tex, replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear
keep if Group=="Democrats"

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="BLM" if DV=="sgroup_favorability_blm"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_democrats.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear

keep if Group=="Democrats"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"

order  DV

texsave * using figureS4a.tex, replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear
keep if Group=="Independents"

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="BLM" if DV=="sgroup_favorability_blm"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_independents.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/majority_minority_groups_clean.dta", clear

keep if Group=="Independents"

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r clustvar beta comma se label_all num coef_label coef_label2 se_label se_label2 Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"

order  DV

texsave * using figureS5b.tex, replace


*******Attitudes towards in/out racial groups
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

	*Whites
	rdrobust sgroup_favorability_blacks running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // 
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", detail(all) addlabel(Group, White, DV, sgroup_favorability_blacks) replace

	*Blacks
	rdrobust sgroup_favorability_blacks running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) //
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", detail(all) addlabel(Group, Black, DV, sgroup_favorability_blacks) append

	*AAPI
	rdrobust sgroup_favorability_blacks running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // 
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", detail(all) addlabel(Group, Asian, DV, sgroup_favorability_blacks) append

foreach var in  group_favorability_whites group_favorability_asians  {
	
	*Whites
	rdrobust s`var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // 
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", detail(all) addlabel(Group, White, DV, s`var') append
	
	*Blacks
	rdrobust s`var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // 
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", detail(all) addlabel(Group, Black, DV, s`var') append

	*AAPI
	rdrobust s`var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // 
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", detail(all) addlabel(Group, Asian, DV, s`var') append

}



use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", clear

replace DV="Asian Disfavorability" if DV=="sgroup_favorability_asians"
replace DV="Black Disfavorability" if DV=="sgroup_favorability_blacks"
replace DV="White Disfavorability" if DV=="sgroup_favorability_whites"

replace Group="Asian Subgroup" if Group=="Asian"
replace Group="Black Subgroup" if Group=="Black"
replace Group="White Subgroup" if Group=="White"

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups_cleaned.dta", replace version(12)

*Table generating, 6

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/in_out_groups.dta", clear

order Group 
drop var level cmd depvar runningvar outcomevar clustvar vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r 


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

replace DV="Asian Dis." if DV=="sgroup_favorability_asians"
replace DV="Black Dis." if DV=="sgroup_favorability_blacks"
replace DV="White Dis." if DV=="sgroup_favorability_whites"

order Group DV

texsave * using figure6.tex, replace

*Attitudes towards in/out party--affective polarization
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

	*Views of Republicans, Among Democrats
	rdrobust sgroup_favorability_republicans running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/party_in_out_groups.dta", detail(all) addlabel(Group, Democrat Subgroup, DV, Republican Disfavorability) replace
	
	*Views of Republicans, Among Republicans
	rdrobust sgroup_favorability_republicans running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/party_in_out_groups.dta", detail(all) addlabel(Group, Republican Subgroup, DV, Republican Disfavorability) append

foreach var in  group_favorability_democrats  {

	*Views of Democrats, Among Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/party_in_out_groups.dta", detail(all) addlabel(Group, Democrat Subgroup, DV, Democrat Disfavorability) append

	*Views of Democrats, Among Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/party_in_out_groups.dta", detail(all) addlabel(Group, Republican Subgroup, DV, Democrat Disfavorability) append

}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/party_in_out_groups.dta", clear


capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)


saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/party_in_out_groups_clean.dta", version(12) replace


*Table generating, 5

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/party_in_out_groups.dta", clear

order Group 
drop var level cmd depvar runningvar outcomevar clustvar vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r 


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order Group DV

texsave * using figure5.tex, replace

*************************** SPRING CUTOFF - ALL ********************************************
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sum c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sconservative_policy sconservatisim scand_favorability_trump scand_favorability_biden  sgroup_favorability_democrats sgroup_favorability_republicans sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews if running_dst_2020<32 & running_dst_2020>-32 //  53,658 observations near the cutoff
sum c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sconservative_policy sconservatisim scand_favorability_trump scand_favorability_biden  sgroup_favorability_democrats sgroup_favorability_republicans sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews if running_dst_2020<8 & running_dst_2020>-8 //   13,299  observations near the cutoff

	rdrobust sconservatisim  running_dst_2020, all vce(cluster running_dst_2020) h(31) b(31)  // all


sort start_date

	rdrobust sconservative_policy running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	

foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust s`var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust s`var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust `var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust `var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta", clear

sum coef, d
sum h_l, d
sum b_l, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Independents"
tab equivalence_cohen_small if Group=="Other Party"
tab equivalence_cohen_small if Group=="Black"
tab equivalence_cohen_small if Group=="White"
tab equivalence_cohen_small if Group=="Asian"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_clean.dta", version(12) replace

hist coef if prob==0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist.pdf", as(pdf) name("Graph") replace

hist coef if prob==1, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist.pdf", as(pdf) name("Graph") replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_clean.dta", clear

replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"

drop if DV=="sconservatisim" | DV=="sconservative_policy" // just mentioned

keep DV Group sig equivalence_cohen_small equivalence_10

gen Group_num=1 if Group=="All"
replace Group_num=2 if Group=="Republicans"
replace Group_num=3 if Group=="Democrats"
replace Group_num=4 if Group=="Independents"
replace Group_num=5 if Group=="Other Party"
replace Group_num=6 if Group=="White"
replace Group_num=7 if Group=="Black"
replace Group_num=8 if Group=="Asian"

gen DV_num=1 if   DV== "Gender Resentment" 
replace DV_num=2 if    DV== "Racial Resentment" 
replace DV_num=3 if    DV== "Pres Challenger" 
replace DV_num=4 if    DV== "Pres Incumbent"  
replace DV_num=5 if    DV== "Whites" 
replace DV_num=6 if    DV== "Blacks" 
replace DV_num=7 if    DV== "Latinos" 
replace DV_num=8 if    DV== "Asians" 
replace DV_num=9 if    DV== "Evangelicals" 
replace DV_num=10 if    DV== "Socialists" 
replace DV_num=11 if    DV== "Muslims" 
replace DV_num=12 if    DV== "Unions" 
replace DV_num=13 if    DV== "Police" 
replace DV_num=14 if    DV== "Undocumented" 
replace DV_num=15 if    DV== "LGBT" 
replace DV_num=16 if    DV== "White Men" 
replace DV_num=17 if    DV== "Jews" 
replace DV_num=18 if    DV== "Democrats" 
replace DV_num=19 if    DV== "Republicans" 
replace DV_num=20 if    DV== "Limit Magazines" 
replace DV_num=21 if    DV== "Ban ARs" 
replace DV_num=22 if    DV== "Ban Guns" 
replace DV_num=23 if    DV== "Deport Immigrants" 
replace DV_num=24 if    DV== "Citizenship Dreamers" 
replace DV_num=25 if    DV== "Path Citizenship" 
replace DV_num=26 if    DV== "Health Subsidies" 
replace DV_num=27 if    DV== "Public Option" 
replace DV_num=28 if    DV== "Gov. Insurance" 
replace DV_num=29 if    DV== "Late Abortion" 
replace DV_num=30 if    DV== "Abortion Never" 
replace DV_num=31 if    DV== "College Debt" 
replace DV_num=32 if    DV== "Raise Tax Upper" 
replace DV_num=33 if    DV== "Eliminate Estate Tax" 
replace DV_num=34 if    DV== "Background Checks" 
replace DV_num=35 if    DV== "Cap Carbon" 
replace DV_num=36 if    DV== "Build Wall"

drop if DV=="conservatisim"

tab equivalence_cohen_small 
tab equivalence_10 

tab sig equivalence_cohen_small, cell // 1.04% are significant and can't rule out Cohen small effects/20% probability 
tab sig equivalence_10, cell // 3.47% are significant and can't rule out Cohen small effects/10% probability 

*For Outcomes: 1 = "Gender Resentment"; 2 = "Racial Resentment"; 3 = "Pres Challenger"; 4 = "Pres Incumbent"; 5 = "Whites"; 6 = "Blacks";7 = "Latinos"; 8 = "Asians"; 9 = "Evangelicals"; 10 = "Socialists"; 11 = "Muslims"; 12 = "Unions"; 13 = "Police"; 14 = "Undocumented"; 15 = "LGBT"; 16 = "White Men"; 17 = "Jews"; 18 = "Democrats"; 19 = "Republicans"; 20 = "Limit Magazines"; 21 = "Ban ARs"; 22 = "Ban Guns"; 23 = "Deport Immigrants"; 24 = "Citizenship Dreamers"; 25 = "Path Citizenship"; 26 = "Health Subsidies"; 27 = "Public Option"; 28 = "Gov. Insurance"; 29 = "Late Abortion"; 30 = "Abortion Never"; 31 = "College Debt"; 32 = "Raise Tax Upper"; 33 = "Eliminate Estate Tax"; 34 = "Background Checks"; 35 = "Cap Carbon"; 36 = "Build Wall"

*For Subgroups 1 = "All"; 2 = "Republicans"; 3 = "Democrats"; 4 = "Independents"; 5 = "Other Party"; 6 = "Whites"; 7 = "Blacks"; 8 = "Asians"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_clean.dta", replace version(12)

*************************** SPRING CUTOFF - MONDAY AFTER IS TREATMENT ***********************************

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

tab start_day_num if start_daytr=="09mar2020"
gen running_dst_2020_monday_spr=start_day_num-21983


	rdrobust sconservative_policy running_dst_2020_monday_spr, all vce(cluster running_dst_2020_monday_spr) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020_monday_spr if pid3==1, all vce(cluster running_dst_2020_monday_spr) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020_monday_spr if pid3==2, all vce(cluster running_dst_2020_monday_spr) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020_monday_spr if pid3==3, all vce(cluster running_dst_2020_monday_spr) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020_monday_spr if pid3==4, all vce(cluster running_dst_2020_monday_spr) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020_monday_spr if race_ethnicity==1, all vce(cluster running_dst_2020_monday_spr) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020_monday_spr if race_ethnicity==2, all vce(cluster running_dst_2020_monday_spr) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020_monday_spr if aapi_race==1, all vce(cluster running_dst_2020_monday_spr) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
		rdrobust sconservatisim running_dst_2020_monday_spr if pid3==2, all vce(cluster running_dst_2020_monday_spr) // Republicans

	
foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020_monday_spr, all vce(cluster running_dst_2020_monday_spr) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020_monday_spr if pid3==1, all vce(cluster running_dst_2020_monday_spr) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020_monday_spr if pid3==2, all vce(cluster running_dst_2020_monday_spr) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020_monday_spr if pid3==3, all vce(cluster running_dst_2020_monday_spr) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020_monday_spr if pid3==4, all vce(cluster running_dst_2020_monday_spr) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020_monday_spr if race_ethnicity==1, all vce(cluster running_dst_2020_monday_spr) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust s`var' running_dst_2020_monday_spr if race_ethnicity==2, all vce(cluster running_dst_2020_monday_spr) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust s`var' running_dst_2020_monday_spr if aapi_race==1, all vce(cluster running_dst_2020_monday_spr) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020_monday_spr, all vce(cluster running_dst_2020_monday_spr) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020_monday_spr if pid3==1, all vce(cluster running_dst_2020_monday_spr) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020_monday_spr if pid3==2, all vce(cluster running_dst_2020_monday_spr) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020_monday_spr if pid3==3, all vce(cluster running_dst_2020_monday_spr) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020_monday_spr if pid3==4, all vce(cluster running_dst_2020_monday_spr) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020_monday_spr if race_ethnicity==1, all vce(cluster running_dst_2020_monday_spr) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust `var' running_dst_2020_monday_spr if race_ethnicity==2, all vce(cluster running_dst_2020_monday_spr) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust `var' running_dst_2020_monday_spr if aapi_race==1, all vce(cluster running_dst_2020_monday_spr) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday.dta", clear

sum coef, d

capture drop t sig abs_coef DV_standardize lb95 ub95 equivalence_cohen_small equivalence_10
gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Independents"
tab equivalence_cohen_small if Group=="Other Party"
tab equivalence_cohen_small if Group=="Black"
tab equivalence_cohen_small if Group=="White"
tab equivalence_cohen_small if Group=="Asian"

tab sig equivalence_cohen_small

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

sum coef

replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday_clean.dta", version(12) replace

keep if Group=="All"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday_clean_all.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday_clean_all.dta", clear

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r  t sig abs_coef Group clustvar DV_standardize lb95 ub95 equivalence_cohen_small equivalence_10 probability


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"

order  DV

texsave * using figureS10.tex, replace



use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday_clean.dta", clear

replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"

drop if DV=="sconservatisim" | DV=="sconservative_policy" // just mentioned

keep DV Group sig equivalence_cohen_small equivalence_10

gen Group_num=1 if Group=="All"
replace Group_num=2 if Group=="Republicans"
replace Group_num=3 if Group=="Democrats"
replace Group_num=4 if Group=="Independents"
replace Group_num=5 if Group=="Other Party"
replace Group_num=6 if Group=="White"
replace Group_num=7 if Group=="Black"
replace Group_num=8 if Group=="Asian"

gen DV_num=1 if   DV== "Gender Resentment" 
replace DV_num=2 if    DV== "Racial Resentment" 
replace DV_num=3 if    DV== "Pres Challenger" 
replace DV_num=4 if    DV== "Pres Incumbent"  
replace DV_num=5 if    DV== "Whites" 
replace DV_num=6 if    DV== "Blacks" 
replace DV_num=7 if    DV== "Latinos" 
replace DV_num=8 if    DV== "Asians" 
replace DV_num=9 if    DV== "Evangelicals" 
replace DV_num=10 if    DV== "Socialists" 
replace DV_num=11 if    DV== "Muslims" 
replace DV_num=12 if    DV== "Unions" 
replace DV_num=13 if    DV== "Police" 
replace DV_num=14 if    DV== "Undocumented" 
replace DV_num=15 if    DV== "LGBT" 
replace DV_num=16 if    DV== "White Men" 
replace DV_num=17 if    DV== "Jews" 
replace DV_num=18 if    DV== "Democrats" 
replace DV_num=19 if    DV== "Republicans" 
replace DV_num=20 if    DV== "Limit Magazines" 
replace DV_num=21 if    DV== "Ban ARs" 
replace DV_num=22 if    DV== "Ban Guns" 
replace DV_num=23 if    DV== "Deport Immigrants" 
replace DV_num=24 if    DV== "Citizenship Dreamers" 
replace DV_num=25 if    DV== "Path Citizenship" 
replace DV_num=26 if    DV== "Health Subsidies" 
replace DV_num=27 if    DV== "Public Option" 
replace DV_num=28 if    DV== "Gov. Insurance" 
replace DV_num=29 if    DV== "Late Abortion" 
replace DV_num=30 if    DV== "Abortion Never" 
replace DV_num=31 if    DV== "College Debt" 
replace DV_num=32 if    DV== "Raise Tax Upper" 
replace DV_num=33 if    DV== "Eliminate Estate Tax" 
replace DV_num=34 if    DV== "Background Checks" 
replace DV_num=35 if    DV== "Cap Carbon" 
replace DV_num=36 if    DV== "Build Wall"

drop if DV=="conservatisim"

tab equivalence_cohen_small 
tab equivalence_10 

tab sig equivalence_cohen_small, cell // 1.04% are significant and can't rule out Cohen small effects/20% probability 
tab sig equivalence_10, cell // 3.47% are significant and can't rule out Cohen small effects/10% probability 

*For Outcomes: 1 = "Gender Resentment"; 2 = "Racial Resentment"; 3 = "Pres Challenger"; 4 = "Pres Incumbent"; 5 = "Whites"; 6 = "Blacks";7 = "Latinos"; 8 = "Asians"; 9 = "Evangelicals"; 10 = "Socialists"; 11 = "Muslims"; 12 = "Unions"; 13 = "Police"; 14 = "Undocumented"; 15 = "LGBT"; 16 = "White Men"; 17 = "Jews"; 18 = "Democrats"; 19 = "Republicans"; 20 = "Limit Magazines"; 21 = "Ban ARs"; 22 = "Ban Guns"; 23 = "Deport Immigrants"; 24 = "Citizenship Dreamers"; 25 = "Path Citizenship"; 26 = "Health Subsidies"; 27 = "Public Option"; 28 = "Gov. Insurance"; 29 = "Late Abortion"; 30 = "Abortion Never"; 31 = "College Debt"; 32 = "Raise Tax Upper"; 33 = "Eliminate Estate Tax"; 34 = "Background Checks"; 35 = "Cap Carbon"; 36 = "Build Wall"

*For Subgroups 1 = "All"; 2 = "Republicans"; 3 = "Democrats"; 4 = "Independents"; 5 = "Other Party"; 6 = "Whites"; 7 = "Blacks"; 8 = "Asians"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_monday_clean.dta", replace version(12)

*************************** Gender Resentment by Gender *************************************************

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

replace gender=0 if gender==2
rename gender female

rdrobust gender_resentment running_dst_2020, all vce(cluster running_dst_2020) // all
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/gender_resentment_by_gender.dta", detail(all) addlabel(Group, All, DV, Gender Resentment) replace

rdrobust gender_resentment running_dst_2020 if female==1, all vce(cluster running_dst_2020) // all
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/gender_resentment_by_gender.dta", detail(all) addlabel(Group, Females, DV, Gender Resentment) append

rdrobust gender_resentment running_dst_2020 if female==0, all vce(cluster running_dst_2020) // all
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/gender_resentment_by_gender.dta", detail(all) addlabel(Group, Males, DV, Gender Resentment) append

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/gender_resentment_by_gender.dta", clear

gen num=-_n


capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)


saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/gender_resentment_by_gender_clean.dta", replace version(12)

*Table generating, 7

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/gender_resentment_by_gender.dta", clear

order Group 
drop var level cmd depvar runningvar outcomevar clustvar vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r DV


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figure7.tex, replace

*************************** Religious Resentment by Religion ********************************************

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

tab religion, gen(religion_num_)

*WIDER BW BC FEWER OBS

*** VIEWS TOWARDS JEWS
rdrobust group_favorability_jews running_dst_2020 if religion_num_1==1, all vce(cluster running_dst_2020) h(120) b(120) // protestants
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Protestants, DV, Jews) replace

rdrobust group_favorability_jews running_dst_2020 if religion_num_2==1, all vce(cluster running_dst_2020) h(120) b(120) // catholic
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Catholics, DV, Jews) append

rdrobust group_favorability_jews running_dst_2020 if religion_num_5==1, all vce(cluster running_dst_2020) h(120) b(120) // other christ
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Other Christian, DV, Jews) append

rdrobust group_favorability_jews running_dst_2020 if religion_num_6==1, all vce(cluster running_dst_2020) h(120) b(120) // jews
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Jews, DV, Jews) append

rdrobust group_favorability_jews running_dst_2020 if religion_num_7==1, all vce(cluster running_dst_2020) h(120) b(120) // Muslims
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Muslims, DV, Jews) append

*** VIEWS TOWARDS EVANGELICALS
rdrobust group_favorability_evangelicals running_dst_2020 if religion_num_1==1, all vce(cluster running_dst_2020) h(120) b(120) // protestants
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Protestants, DV, Evangelicals) append

rdrobust group_favorability_evangelicals running_dst_2020 if religion_num_2==1, all vce(cluster running_dst_2020) h(120) b(120) // catholic
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Catholics, DV, Evangelicals) append

rdrobust group_favorability_evangelicals running_dst_2020 if religion_num_5==1, all vce(cluster running_dst_2020) h(120) b(120) // other christ
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Other Christian, DV, Evangelicals) append

rdrobust group_favorability_evangelicals running_dst_2020 if religion_num_6==1, all vce(cluster running_dst_2020) h(120) b(120) // jews
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Jews, DV, Evangelicals) append

rdrobust group_favorability_evangelicals running_dst_2020 if religion_num_7==1, all vce(cluster running_dst_2020) h(120) b(120) // Muslims
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Muslims, DV, Evangelicals) append

*** VIEWS TOWARDS MUSLIMS
rdrobust group_favorability_muslims running_dst_2020 if religion_num_1==1, all vce(cluster running_dst_2020) h(120) b(120) // protestants
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Protestants, DV, Muslims) append

rdrobust group_favorability_muslims running_dst_2020 if religion_num_2==1, all vce(cluster running_dst_2020) h(120) b(120) // catholic
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Catholics, DV, Muslims) append

rdrobust group_favorability_muslims running_dst_2020 if religion_num_5==1, all vce(cluster running_dst_2020) h(120) b(120) // other christ
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Other Christian, DV, Muslims) append

rdrobust group_favorability_muslims running_dst_2020 if religion_num_6==1, all vce(cluster running_dst_2020) h(120) b(120) // jews
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Jews, DV, Muslims) append

rdrobust group_favorability_muslims running_dst_2020 if religion_num_7==1, all vce(cluster running_dst_2020) h(120) b(120) // Muslims
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", detail(all) addlabel(Group, Muslims, DV, Muslims) append


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", clear

replace Group="Muslims" if Group=="Muslisms"

gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

*Analysis

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small
tab sig equivalence_cohen_small, cell

tab equivalence_10
tab sig equivalence_10, cell


saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion_clean.dta", replace version(12)

*Table generating, 8

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/religion_by_religion.dta", clear

order Group 
drop var level cmd depvar runningvar outcomevar clustvar vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r 


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order Group DV

texsave * using figure8.tex, replace

*************************** SPRING CUTOFF - ALL, WITH COVARS ********************************************
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

	rdrobust group_favorability_asians running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020)  covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Asian


	rdrobust sconservative_policy running_dst_2020, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
		rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // all
		
	
foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust s`var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust s`var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust `var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust `var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs.dta", clear

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Independents"
tab equivalence_cohen_small if Group=="Other Party"
tab equivalence_cohen_small if Group=="Black"
tab equivalence_cohen_small if Group=="White"
tab equivalence_cohen_small if Group=="Asian"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

drop covs

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs_clean.dta", version(12) replace 

hist coef if prob==0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist_covs.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist_covs.pdf", as(pdf) name("Graph") replace

hist coef if prob==1, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist_covs.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist_covs.pdf", as(pdf) name("Graph") replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs_clean.dta", clear

replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"

drop if DV=="sconservatisim" | DV=="sconservative_policy" // just mentioned

keep DV Group sig equivalence_cohen_small equivalence_10

gen Group_num=1 if Group=="All"
replace Group_num=2 if Group=="Republicans"
replace Group_num=3 if Group=="Democrats"
replace Group_num=4 if Group=="Independents"
replace Group_num=5 if Group=="Other Party"
replace Group_num=6 if Group=="White"
replace Group_num=7 if Group=="Black"
replace Group_num=8 if Group=="Asian"

gen DV_num=1 if   DV== "Gender Resentment" 
replace DV_num=2 if    DV== "Racial Resentment" 
replace DV_num=3 if    DV== "Pres Challenger" 
replace DV_num=4 if    DV== "Pres Incumbent"  
replace DV_num=5 if    DV== "Whites" 
replace DV_num=6 if    DV== "Blacks" 
replace DV_num=7 if    DV== "Latinos" 
replace DV_num=8 if    DV== "Asians" 
replace DV_num=9 if    DV== "Evangelicals" 
replace DV_num=10 if    DV== "Socialists" 
replace DV_num=11 if    DV== "Muslims" 
replace DV_num=12 if    DV== "Unions" 
replace DV_num=13 if    DV== "Police" 
replace DV_num=14 if    DV== "Undocumented" 
replace DV_num=15 if    DV== "LGBT" 
replace DV_num=16 if    DV== "White Men" 
replace DV_num=17 if    DV== "Jews" 
replace DV_num=18 if    DV== "Democrats" 
replace DV_num=19 if    DV== "Republicans" 
replace DV_num=20 if    DV== "Limit Magazines" 
replace DV_num=21 if    DV== "Ban ARs" 
replace DV_num=22 if    DV== "Ban Guns" 
replace DV_num=23 if    DV== "Deport Immigrants" 
replace DV_num=24 if    DV== "Citizenship Dreamers" 
replace DV_num=25 if    DV== "Path Citizenship" 
replace DV_num=26 if    DV== "Health Subsidies" 
replace DV_num=27 if    DV== "Public Option" 
replace DV_num=28 if    DV== "Gov. Insurance" 
replace DV_num=29 if    DV== "Late Abortion" 
replace DV_num=30 if    DV== "Abortion Never" 
replace DV_num=31 if    DV== "College Debt" 
replace DV_num=32 if    DV== "Raise Tax Upper" 
replace DV_num=33 if    DV== "Eliminate Estate Tax" 
replace DV_num=34 if    DV== "Background Checks" 
replace DV_num=35 if    DV== "Cap Carbon" 
replace DV_num=36 if    DV== "Build Wall"

drop if DV=="conservatisim"

tab equivalence_cohen_small 
tab equivalence_10 

tab sig equivalence_cohen_small, cell // 1.04% are significant and can't rule out Cohen small effects/20% probability 
tab sig equivalence_10, cell // 3.47% are significant and can't rule out Cohen small effects/10% probability 


*For Outcomes: 1 = "Gender Resentment"; 2 = "Racial Resentment"; 3 = "Pres Challenger"; 4 = "Pres Incumbent"; 5 = "Whites"; 6 = "Blacks";7 = "Latinos"; 8 = "Asians"; 9 = "Evangelicals"; 10 = "Socialists"; 11 = "Muslims"; 12 = "Unions"; 13 = "Police"; 14 = "Undocumented"; 15 = "LGBT"; 16 = "White Men"; 17 = "Jews"; 18 = "Democrats"; 19 = "Republicans"; 20 = "Limit Magazines"; 21 = "Ban ARs"; 22 = "Ban Guns"; 23 = "Deport Immigrants"; 24 = "Citizenship Dreamers"; 25 = "Path Citizenship"; 26 = "Health Subsidies"; 27 = "Public Option"; 28 = "Gov. Insurance"; 29 = "Late Abortion"; 30 = "Abortion Never"; 31 = "College Debt"; 32 = "Raise Tax Upper"; 33 = "Eliminate Estate Tax"; 34 = "Background Checks"; 35 = "Cap Carbon"; 36 = "Build Wall"

*For Subgroups 1 = "All"; 2 = "Republicans"; 3 = "Democrats"; 4 = "Independents"; 5 = "Other Party"; 6 = "Whites"; 7 = "Blacks"; 8 = "Asians"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_covs_clean.dta", replace version(12)


************************************************************************************
************************************************************************************
************************************************************************************
************************************************************************************
************************************************************************************
*************************** ADDITIONAL ANALYSES ************************************
************************************************************************************
************************************************************************************
************************************************************************************
************************************************************************************

******** COVARIATE BALANCE
use "nsALLCLEAN.dta", clear

sum age pid3 employment foreign_born language religion  gender census_region race_ethnicity household_income education married

tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

	rdrobust over_60 running_dst_2020, all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covariatebalance.dta", detail(all) addlabel(DV, age) replace


foreach var in party_1 party_2 party_3 party_4 unemployed foreign_born english_only female religion_num_1 religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13 census_region_num_1 census_region_num_2 census_region_num_3 census_region_num_4 race_ethnicity_num_1 race_ethnicity_num_2 race_ethnicity_num_3 race_ethnicity_num_4 race_ethnicity_num_5 race_ethnicity_num_6 race_ethnicity_num_7 race_ethnicity_num_8 race_ethnicity_num_9 race_ethnicity_num_10 race_ethnicity_num_11 race_ethnicity_num_12 race_ethnicity_num_13 race_ethnicity_num_14 race_ethnicity_num_15 over_median_income over_median_ed {
	rdrobust `var' running_dst_2020, all h(30) b(30)
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covariatebalance.dta", detail(all) addlabel(DV, `var') append

}

*analysis
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covariatebalance.dta", clear

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covariatebalance_clean.dta", version(12) replace


*Table generating, S1b

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covariatebalance.dta", clear

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

texsave * using figureS1b.tex, replace

******** DISTRIBUTION OF RESPONDENTS
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here
use "nsALLCLEAN.dta", clear

drop if running_dst_2020>180 | running_dst_2020<-180 // for sake of visualization

hist running_dst_2020, frequency kdensity
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Days Since DST Started
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1._xylines[1].style.editstyle linestyle(width(thick)) editcopy

egen weight_std=std(weight), mean(0) std(1)

rdrobust weight_std running_dst_2020, all // slightly lower weight around the cutoff--baby effect size; deal with perhaps slightly more respondents after treatment. Don't think this is an issue, but we can deal with any of this issue below with the donut. 

* residualized dow model

gen state_day_numerical_day=substr(start_daytr, 1, 2)

gen state_day_numerical_month=1 if start_day_month=="jan"
replace state_day_numerical_month=2 if start_day_month=="feb"
replace state_day_numerical_month=3 if start_day_month=="mar"
replace state_day_numerical_month=4 if start_day_month=="apr"
replace state_day_numerical_month=5 if start_day_month=="may"
replace state_day_numerical_month=6 if start_day_month=="jun"
replace state_day_numerical_month=7 if start_day_month=="jul"
replace state_day_numerical_month=8 if start_day_month=="aug"
replace state_day_numerical_month=9 if start_day_month=="sep"
replace state_day_numerical_month=10 if start_day_month=="oct"
replace state_day_numerical_month=11 if start_day_month=="nov"
replace state_day_numerical_month=12 if start_day_month=="dec"

destring start_day_year, replace
destring state_day_numerical_day, replace
destring state_day_numerical_month, replace

order state_day_numerical_month  state_day_numerical_day start_day_year
gen dow = dow( mdy( state_day_numerical_month, state_day_numerical_day, start_day_year) )

gen respondent_count=1

collapse (sum) respondent_count (first) dow running_dst_2020 (mean) weight, by(start_daytr)

regress respondent_count i.dow
predict response, xb
predict residual, residuals

hist residual, frequency kdensity

egen residual_std=std(residual), mean(0) std(1)

gen respondent_count_weighted= respondent_count*weight

rdrobust respondent_count running_dst_2020, all h(90) b(90) // positive not significant
rdrobust respondent_count_weighted running_dst_2020, all h(90) b(90)  // positive not significant
rdrobust residual running_dst_2020, all h(90) b(90) // positive not significant
rdrobust residual_std running_dst_2020, all h(90) b(90) //. small/modest and not signficiant positive coef on residuals (miss)--we see more respondents that expected based only on the day of the week, but that's not stat sig

******** Donut RDD--to address issue above, no change to results--all null
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here
use "nsALLCLEAN.dta", clear

gen running_dst_2020_donut=running_dst_2020
replace running_dst_2020_donut=. if running_dst_2020_donut>-2 & running_dst_2020_donut<2

*** Models
rdrobust sconservative_policy running_dst_2020_donut, all
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/donut.dta", detail(all) addlabel(Group, Without FE, DV, sconservative_policy) replace

foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	rdrobust s`var' running_dst_2020_donut, all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/donut.dta", detail(all) addlabel(Group, Without FE, DV, s`var') append

}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020_donut, all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/donut.dta", detail(all) addlabel(Group, Without FE, DV, `var') append

}

*Analysis
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/donut.dta", clear

sum coef

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef // all rule out very small effects
list 


replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"


saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/donut_clean.dta", version(12) replace



use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/donut_clean.dta", clear

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r  t sig abs_coef Group


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"

order  DV

texsave * using figureS8.tex, replace

******** DOW FE
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here
use "nsALLCLEAN.dta", clear

gen state_day_numerical_day=substr(start_daytr, 1, 2)

gen state_day_numerical_month=1 if start_day_month=="jan"
replace state_day_numerical_month=2 if start_day_month=="feb"
replace state_day_numerical_month=3 if start_day_month=="mar"
replace state_day_numerical_month=4 if start_day_month=="apr"
replace state_day_numerical_month=5 if start_day_month=="may"
replace state_day_numerical_month=6 if start_day_month=="jun"
replace state_day_numerical_month=7 if start_day_month=="jul"
replace state_day_numerical_month=8 if start_day_month=="aug"
replace state_day_numerical_month=9 if start_day_month=="sep"
replace state_day_numerical_month=10 if start_day_month=="oct"
replace state_day_numerical_month=11 if start_day_month=="nov"
replace state_day_numerical_month=12 if start_day_month=="dec"

destring start_day_year, replace
destring state_day_numerical_day, replace
destring state_day_numerical_month, replace

order state_day_numerical_month  state_day_numerical_day start_day_year

// this gives 0=Sunday,...,6=Saturday.
gen dow = dow( mdy( state_day_numerical_month, state_day_numerical_day, start_day_year) )

tab dow, gen(dow_) 

*** Models with and without
rdrobust sconservative_policy running_dst_2020, all
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta", detail(all) addlabel(Group, Without FE, DV, sconservative_policy) replace

rdrobust sconservative_policy running_dst_2020, covs(dow_2 dow_3 dow_4 dow_5 dow_6 dow_7) all
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta", detail(all) addlabel(Group, With FE, DV, sconservative_policy) append

foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	rdrobust s`var' running_dst_2020, all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta", detail(all) addlabel(Group, Without FE, DV, s`var') append

	rdrobust s`var' running_dst_2020, covs(dow_2 dow_3 dow_4 dow_5 dow_6 dow_7) all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta", detail(all) addlabel(Group, With FE, DV, s`var') append

}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020	, all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta", detail(all) addlabel(Group, Without FE, DV, `var') append

	rdrobust `var' running_dst_2020, covs(dow_2 dow_3 dow_4 dow_5 dow_6 dow_7) all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta", detail(all) addlabel(Group, With FE, DV, `var') append

}


*Analysis
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta", clear


sum coef

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef // all rule out very small effects
list 


replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"

drop if Group=="Without FE"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe_clean.dta", version(12) replace


use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe_clean.dta", clear

drop var level cmd depvar runningvar outcomevar  vce_select bwselect kernel ci_rb properties c p q tau_cl tau_bc tau_cl_l tau_cl_r tau_bc_l pv_cl ci_r_cl ci_l_cl se_tau_rb se_tau_cl bias_r bias_l tau_bc_r N_l N_r N_h_l N_h_r N_b_l N_b_r  t sig abs_coef Group covs


foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order DV

replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"

order  DV

texsave * using figureS9.tex, replace

******** With Covariates [takes hours to run]
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here
use "nsALLCLEAN.dta", clear

tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

*** Models
rdrobust sconservative_policy running_dst_2020, all covs(party_2 party_3 party_4 unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4  race_ethnicity_num_2 race_ethnicity_num_3 race_ethnicity_num_4 race_ethnicity_num_5 race_ethnicity_num_6 race_ethnicity_num_7 race_ethnicity_num_8 race_ethnicity_num_9 race_ethnicity_num_10 race_ethnicity_num_11 race_ethnicity_num_12 race_ethnicity_num_13 race_ethnicity_num_14 race_ethnicity_num_15 over_median_income over_median_ed)
regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covars.dta", detail(all) addlabel(Group, Without FE, DV, sconservative_policy) replace

foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	rdrobust s`var' running_dst_2020, all covs(party_2 party_3 party_4 unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4  race_ethnicity_num_2 race_ethnicity_num_3 race_ethnicity_num_4 race_ethnicity_num_5 race_ethnicity_num_6 race_ethnicity_num_7 race_ethnicity_num_8 race_ethnicity_num_9 race_ethnicity_num_10 race_ethnicity_num_11 race_ethnicity_num_12 race_ethnicity_num_13 race_ethnicity_num_14 race_ethnicity_num_15 over_median_income over_median_ed)
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covars.dta", detail(all) addlabel(Group, Without FE, DV, s`var') append

}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020, all covs(party_2 party_3 party_4 unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4  race_ethnicity_num_2 race_ethnicity_num_3 race_ethnicity_num_4 race_ethnicity_num_5 race_ethnicity_num_6 race_ethnicity_num_7 race_ethnicity_num_8 race_ethnicity_num_9 race_ethnicity_num_10 race_ethnicity_num_11 race_ethnicity_num_12 race_ethnicity_num_13 race_ethnicity_num_14 race_ethnicity_num_15 over_median_income over_median_ed)
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covars.dta", detail(all) addlabel(Group, Without FE, DV, `var') append

}

*Analysis
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/covars.dta", clear

order Group

sum coef

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig Group, col



gen abs_coef=abs(coef)
sort abs_coef

replace Group="With Covars"

*relative to other models
append using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/dow_fe.dta"

encode Group, gen(Group_num)

drop t
gen t=coef/stderr

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2
tab equivalence_cohen_small

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1
tab equivalence_10

regress coef i.Group_num
regress t i.Group_num
regress coef i.Group_num // no differences in any of these across covars, dow fe, or just raw

******** START UP ENGAGEMENT LEVELS, NO FOLLOW THROUGH MEASURES, SADLY
use "nsALLCLEAN.dta", clear

*Not about the start up, but the follow through--confirms HSD and SH (footnote in the paper)
rdrobust interest_flipped running_dst_2020 if start_day_year=="2020"
rdrobust intend_vote running_dst_2020 if start_day_year=="2020"


******************************differences in R/D perceptions at the national level ******************************

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

gen opposite_party_dem_views= group_favorability_republicans if pid3==1
gen opposite_party_rep_views= group_favorability_democrats if pid3==2

egen state_running_dst_2020=concat(running_dst_2020 state)

collapse (mean) opposite_party_dem_views opposite_party_rep_views, by(running_dst_2020)

gen diff_out_party_views=opposite_party_dem_views-opposite_party_rep_views

gen abs_diff_out_party_views=abs(diff_out_party_views)

egen abs_diff_out_party_views_s=std(abs_diff_out_party_views), mean(0) std(1)

rdrobust abs_diff_out_party_views_s running_dst_2020, all vce(cluster running_dst_2020) 
rdrobust abs_diff_out_party_views_s running_dst_2020, all vce(cluster running_dst_2020) h(120) b(120)

*Some separation, driven by changes in Reps perceptions of Democrats


*************************** FALL CUTOFF ********************************************
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

tab start_day_num if start_daytr=="01nov2020"

gen running_dst_2020_fall=start_day_num-22220 

	rdrobust sconservative_policy running_dst_2020_fall, all vce(cluster running_dst_2020_fall) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020_fall if pid3==1, all vce(cluster running_dst_2020_fall) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020_fall if pid3==2, all vce(cluster running_dst_2020_fall) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020_fall if pid3==3, all vce(cluster running_dst_2020_fall) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020_fall if pid3==4, all vce(cluster running_dst_2020_fall) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020_fall if race_ethnicity==1, all vce(cluster running_dst_2020_fall) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020_fall if race_ethnicity==2, all vce(cluster running_dst_2020_fall) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020_fall if aapi_race==1, all vce(cluster running_dst_2020_fall) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020_fall, all vce(cluster running_dst_2020_fall) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020_fall if pid3==1, all vce(cluster running_dst_2020_fall) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020_fall if pid3==2, all vce(cluster running_dst_2020_fall) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020_fall if pid3==3, all vce(cluster running_dst_2020_fall) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020_fall if pid3==4, all vce(cluster running_dst_2020_fall) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020_fall if race_ethnicity==1, all vce(cluster running_dst_2020_fall) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust s`var' running_dst_2020_fall if race_ethnicity==2, all vce(cluster running_dst_2020_fall) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust s`var' running_dst_2020_fall if aapi_race==1, all vce(cluster running_dst_2020_fall) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020_fall, all vce(cluster running_dst_2020_fall) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020_fall if pid3==1, all vce(cluster running_dst_2020_fall) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020_fall if pid3==2, all vce(cluster running_dst_2020_fall) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020_fall if pid3==3, all vce(cluster running_dst_2020_fall) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020_fall if pid3==4, all vce(cluster running_dst_2020_fall) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020_fall if race_ethnicity==1, all vce(cluster running_dst_2020_fall) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust `var' running_dst_2020_fall if race_ethnicity==2, all vce(cluster running_dst_2020_fall) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust `var' running_dst_2020_fall if aapi_race==1, all vce(cluster running_dst_2020_fall) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall.dta", clear

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Democrats"

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"
hist coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

hist coef if prob==0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist.pdf", as(pdf) name("Graph") replace

hist coef if prob==1, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist.pdf", as(pdf) name("Graph") replace

************************* 2019 FALL

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

tab start_day_num if start_daytr=="03nov2019"

gen running_dst_2019_fall=start_day_num-21856 


	rdrobust sconservative_policy running_dst_2019_fall, all vce(cluster running_dst_2019_fall) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2019_fall if pid3==1, all vce(cluster running_dst_2019_fall) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2019_fall if pid3==2, all vce(cluster running_dst_2019_fall) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2019_fall if pid3==3, all vce(cluster running_dst_2019_fall) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2019_fall if pid3==4, all vce(cluster running_dst_2019_fall) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2019_fall if race_ethnicity==1, all vce(cluster running_dst_2019_fall) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2019_fall if race_ethnicity==2, all vce(cluster running_dst_2019_fall) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2019_fall if aapi_race==1, all vce(cluster running_dst_2019_fall) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
	*No group_favorability_jews because not in the survey
	
foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men  /// social views
{
	
	rdrobust s`var' running_dst_2019_fall, all vce(cluster running_dst_2019_fall) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2019_fall if pid3==1, all vce(cluster running_dst_2019_fall) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2019_fall if pid3==2, all vce(cluster running_dst_2019_fall) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2019_fall if pid3==3, all vce(cluster running_dst_2019_fall) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2019_fall if pid3==4, all vce(cluster running_dst_2019_fall) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2019_fall if race_ethnicity==1, all vce(cluster running_dst_2019_fall) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust s`var' running_dst_2019_fall if race_ethnicity==2, all vce(cluster running_dst_2019_fall) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust s`var' running_dst_2019_fall if aapi_race==1, all vce(cluster running_dst_2019_fall) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2019_fall, all vce(cluster running_dst_2019_fall) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2019_fall if pid3==1, all vce(cluster running_dst_2019_fall) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2019_fall if pid3==2, all vce(cluster running_dst_2019_fall) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2019_fall if pid3==3, all vce(cluster running_dst_2019_fall) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2019_fall if pid3==4, all vce(cluster running_dst_2019_fall) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2019_fall if race_ethnicity==1, all vce(cluster running_dst_2019_fall) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust `var' running_dst_2019_fall if race_ethnicity==2, all vce(cluster running_dst_2019_fall) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust `var' running_dst_2019_fall if aapi_race==1, all vce(cluster running_dst_2019_fall) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019.dta", clear

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Democrats"

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"
hist coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"


replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"

drop if DV=="sconservatisim" | DV=="sconservative_policy" // just mentioned

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

keep DV Group sig equivalence_cohen_small equivalence_10

gen Group_num=1 if Group=="All"
replace Group_num=2 if Group=="Republicans"
replace Group_num=3 if Group=="Democrats"
replace Group_num=4 if Group=="Independents"
replace Group_num=5 if Group=="Other Party"
replace Group_num=6 if Group=="White"
replace Group_num=7 if Group=="Black"
replace Group_num=8 if Group=="Asian"

gen DV_num=1 if   DV== "Gender Resentment" 
replace DV_num=2 if    DV== "Racial Resentment" 
replace DV_num=3 if    DV== "Pres Challenger" 
replace DV_num=4 if    DV== "Pres Incumbent"  
replace DV_num=5 if    DV== "Whites" 
replace DV_num=6 if    DV== "Blacks" 
replace DV_num=7 if    DV== "Latinos" 
replace DV_num=8 if    DV== "Asians" 
replace DV_num=9 if    DV== "Evangelicals" 
replace DV_num=10 if    DV== "Socialists" 
replace DV_num=11 if    DV== "Muslims" 
replace DV_num=12 if    DV== "Unions" 
replace DV_num=13 if    DV== "Police" 
replace DV_num=14 if    DV== "Undocumented" 
replace DV_num=15 if    DV== "LGBT" 
replace DV_num=16 if    DV== "White Men" 
replace DV_num=17 if    DV== "Jews" 
replace DV_num=18 if    DV== "Democrats" 
replace DV_num=19 if    DV== "Republicans" 
replace DV_num=20 if    DV== "Limit Magazines" 
replace DV_num=21 if    DV== "Ban ARs" 
replace DV_num=22 if    DV== "Ban Guns" 
replace DV_num=23 if    DV== "Deport Immigrants" 
replace DV_num=24 if    DV== "Citizenship Dreamers" 
replace DV_num=25 if    DV== "Path Citizenship" 
replace DV_num=26 if    DV== "Health Subsidies" 
replace DV_num=27 if    DV== "Public Option" 
replace DV_num=28 if    DV== "Gov. Insurance" 
replace DV_num=29 if    DV== "Late Abortion" 
replace DV_num=30 if    DV== "Abortion Never" 
replace DV_num=31 if    DV== "College Debt" 
replace DV_num=32 if    DV== "Raise Tax Upper" 
replace DV_num=33 if    DV== "Eliminate Estate Tax" 
replace DV_num=34 if    DV== "Background Checks" 
replace DV_num=35 if    DV== "Cap Carbon" 
replace DV_num=36 if    DV== "Build Wall"

drop if DV=="conservatisim"

tab equivalence_cohen_small 
tab equivalence_10 

tab sig equivalence_cohen_small, cell // 1.04% are significant and can't rule out Cohen small effects/20% probability 
tab sig equivalence_10, cell // 3.47% are significant and can't rule out Cohen small effects/10% probability 

*For Outcomes: 1 = "Gender Resentment"; 2 = "Racial Resentment"; 3 = "Pres Challenger"; 4 = "Pres Incumbent"; 5 = "Whites"; 6 = "Blacks";7 = "Latinos"; 8 = "Asians"; 9 = "Evangelicals"; 10 = "Socialists"; 11 = "Muslims"; 12 = "Unions"; 13 = "Police"; 14 = "Undocumented"; 15 = "LGBT"; 16 = "White Men"; 17 = "Jews"; 18 = "Democrats"; 19 = "Republicans"; 20 = "Limit Magazines"; 21 = "Ban ARs"; 22 = "Ban Guns"; 23 = "Deport Immigrants"; 24 = "Citizenship Dreamers"; 25 = "Path Citizenship"; 26 = "Health Subsidies"; 27 = "Public Option"; 28 = "Gov. Insurance"; 29 = "Late Abortion"; 30 = "Abortion Never"; 31 = "College Debt"; 32 = "Raise Tax Upper"; 33 = "Eliminate Estate Tax"; 34 = "Background Checks"; 35 = "Cap Carbon"; 36 = "Build Wall"

*For Subgroups 1 = "All"; 2 = "Republicans"; 3 = "Democrats"; 4 = "Independents"; 5 = "Other Party"; 6 = "Whites"; 7 = "Blacks"; 8 = "Asians"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_fall_2019_cleaned.dta", replace version(12)


hist coef if prob==0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_2019_standardized_dist.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_2019_standardized_dist.pdf", as(pdf) name("Graph") replace

hist coef if prob==1, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_2019_probability_dist.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_2019_probability_dist.pdf", as(pdf) name("Graph") replace


********************************************* NARROW BW

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

	rdrobust sconservative_policy running_dst_2020, all vce(cluster running_dst_2020) h(60) b(60)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(60) b(60)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(60) b(60)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(60) b(60)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(60) b(60)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(60) b(60)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(60) b(60)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(60) b(60)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
		rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(60) b(60)  // Republicans


	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(60) b(60)  // Democrats
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(60) b(60)  // Republicans

	
tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

	
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(60) b(60)  	covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Democrats
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(60) b(60)  	covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Republicans



foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) h(60) b(60)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(60) b(60)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(60) b(60)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(60) b(60)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(60) b(60)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(60) b(60)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust s`var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(60) b(60)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust s`var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(60) b(60)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020, all vce(cluster running_dst_2020) h(60) b(60)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(60) b(60)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(60) b(60)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(60) b(60)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(60) b(60)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(60) b(60)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust `var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(60) b(60)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust `var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(60) b(60)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_narrow.dta", clear

********************************************* 30 DAY BW



cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

	rdrobust sconservative_policy running_dst_2020, all vce(cluster running_dst_2020) h(30) b(30)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(30) b(30)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(30) b(30)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(30) b(30)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(30) b(30)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(30) b(30)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(30) b(30)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(30) b(30)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
		rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(30) b(30)  // Republicans


	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(30) b(30)  // Democrats
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(30) b(30)  // Republicans

	
tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

	
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(30) b(30)  	covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Democrats
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(30) b(30)  	covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Republicans



foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) h(30) b(30)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(30) b(30)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(30) b(30)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(30) b(30)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(30) b(30)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(30) b(30)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust s`var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(30) b(30)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust s`var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(30) b(30)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020, all vce(cluster running_dst_2020) h(30) b(30)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(30) b(30)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(30) b(30)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(30) b(30)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(30) b(30)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(30) b(30)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust `var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(30) b(30)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust `var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(30) b(30)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_30.dta", clear

gen BW="30"

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Independents"
tab equivalence_cohen_small if Group=="Other Party"
tab equivalence_cohen_small if Group=="Black"
tab equivalence_cohen_small if Group=="White"
tab equivalence_cohen_small if Group=="Asian"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

*IGNORE THE FILE NAMES BELOW, THESE ARE SPRING

hist coef if prob==0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_30.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_30.pdf", as(pdf) name("Graph") replace

hist coef if prob==1, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_30.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_30.pdf", as(pdf) name("Graph") replace

*check for differences across BW
append using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta"

replace BW="OPT" if BW==""

encode Group, gen(Group_num)

drop t lb95 ub95 equivalence_cohen_small equivalence_10
gen t=coef/stderr

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2
tab equivalence_cohen_small

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1
tab equivalence_10

encode BW, gen(BW_num)

regress coef i.BW_num
regress t i.BW_num
regress coef i.BW_num // no differences in any of these across covars, dow fe, or just raw

********************************************* 120 DAY BW



cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

	rdrobust sconservative_policy running_dst_2020, all vce(cluster running_dst_2020) h(120) b(120)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, All, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(120) b(120)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(120) b(120)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(120) b(120)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(120) b(120)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(120) b(120)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(120) b(120)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(120) b(120)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
		rdrobust sconservatisim running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(120) b(120)  // Republicans


	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(120) b(120)  // Democrats
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(120) b(120)  // Republicans

	
tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

	
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(120) b(120)  	covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Democrats
	rdrobust sgroup_favorability_democrats running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(120) b(120)  	covs( unemployed foreign_born english_only female  religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13  census_region_num_2 census_region_num_3 census_region_num_4   over_median_income over_median_ed) // Republicans



foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020, all vce(cluster running_dst_2020) h(120) b(120)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, All, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(120) b(120)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(120) b(120)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(120) b(120)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(120) b(120)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(120) b(120)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust s`var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(120) b(120)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust s`var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(120) b(120)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020, all vce(cluster running_dst_2020) h(120) b(120)  // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, All, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) h(120) b(120)  // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) h(120) b(120)  // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) h(120) b(120)  // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) h(120) b(120)  // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) h(120) b(120)  // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust `var' running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) h(120) b(120)  // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust `var' running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) h(120) b(120)  // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_wide.dta", clear

gen BW="120"

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Independents"
tab equivalence_cohen_small if Group=="Other Party"
tab equivalence_cohen_small if Group=="Black"
tab equivalence_cohen_small if Group=="White"
tab equivalence_cohen_small if Group=="Asian"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

*IGNORE THE FILE NAMES BELOW, THESE ARE SPRING

hist coef if prob==0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.4 0.2 0.2 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_120.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_120.pdf", as(pdf) name("Graph") replace

hist coef if prob==1, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.1 0.2 0.1 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_120.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_120.pdf", as(pdf) name("Graph") replace

*check for differences across BW
append using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring.dta"

replace BW="OPT" if BW==""

encode Group, gen(Group_num)

drop t lb95 ub95 equivalence_cohen_small equivalence_10
gen t=coef/stderr

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2
tab equivalence_cohen_small

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1
tab equivalence_10

encode BW, gen(BW_num)

regress coef i.BW_num
regress t i.BW_num
regress coef i.BW_num // no differences in any of these across covars, dow fe, or just raw

********************************************* BY AGE

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

xtile age_4=age, n(4) // breaking it up equally

	*18-31
	rdrobust sconservative_policy running_dst_2020 if age_4==1, all vce(cluster running_dst_2020)   // 18-31
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 18-31, DV, sconservative_policy) replace
	
	*32-44
	rdrobust sconservative_policy running_dst_2020 if age_4==2, all vce(cluster running_dst_2020)   // 32-44
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 32-44, DV, sconservative_policy) append
	
	*45-58
	rdrobust sconservative_policy running_dst_2020 ifage_4==3, all vce(cluster running_dst_2020)   // 45-58
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 45-58, DV, sconservative_policy) append
	
	*59+
	rdrobust sconservative_policy running_dst_2020 if age_4==4, all vce(cluster running_dst_2020)   // 59+
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 59+, DV, sconservative_policy) append
	
tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	*18-31
	rdrobust s`var' running_dst_2020 if age_4==1, all vce(cluster running_dst_2020)   // 18-31
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 18-31, DV, s`var') append
	
	*32-44
	rdrobust s`var' running_dst_2020 if age_4==2, all vce(cluster running_dst_2020)   // 32-44
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 32-44, DV, s`var') append
	
	*45-58
	rdrobust s`var' running_dst_2020 ifage_4==3, all vce(cluster running_dst_2020)   // 45-58
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 45-58, DV, s`var') append
	
	*59+
	rdrobust s`var' running_dst_2020 if age_4==4, all vce(cluster running_dst_2020)   // 59+
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 59+, DV, s`var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {

	*18-31
	rdrobust `var' running_dst_2020 if age_4==1, all vce(cluster running_dst_2020)   // 18-31
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 18-31, DV, `var') append
	
	*32-44
	rdrobust `var' running_dst_2020 if age_4==2, all vce(cluster running_dst_2020)   // 32-44
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 32-44, DV, `var') append
	
	*45-58
	rdrobust `var' running_dst_2020 ifage_4==3, all vce(cluster running_dst_2020)   // 45-58
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 45-58, DV, `var') append
	
	*59+
	rdrobust `var' running_dst_2020 if age_4==4, all vce(cluster running_dst_2020)   // 59+
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", detail(all) addlabel(Group, 59+, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_age.dta", clear

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="32-44"
tab equivalence_cohen_small if Group=="18-31"
tab equivalence_cohen_small if Group=="45-58"
tab equivalence_cohen_small if Group=="59+"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

encode Group, gen(Group_num)

set seed 6809876

bs, reps(100): regress coef ib4.Group_num if prob==1, r
bs, reps(100):regress t ib4.Group_num if prob==1, r

bs, reps(100):regress coef ib4.Group_num if prob==0, r
bs, reps(100):regress t ib4.Group_num if prob==0, r

*IGNORE THE FILE NAMES BELOW, THESE ARE SPRING

hist coef if prob==0 & Group=="18-31", frequency kdensity normal  bin(10) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.2 0.2 0.1 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_18_31.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_18_31.pdf", as(pdf) name("Graph") replace

hist coef if prob==1 & Group=="18-31", frequency kdensity normal bin(10) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.1 0.1 0.05 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_18_31.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_18_31.pdf", as(pdf) name("Graph") replace

 
hist coef if prob==0 & Group=="59+", frequency kdensity normal bin(10) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.2 0.2 0.1 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_18_31.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_standardized_dist_59_plus.pdf", as(pdf) name("Graph") replace

hist coef if prob==1 & Group=="59+", frequency kdensity normal bin(10) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.1 0.1 0.05 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_59_plus.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/fall_probability_dist_59_plus.pdf", as(pdf) name("Graph") replace


********************************** BY EDUCATION


cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

xtile education_4=education, n(4) // breaking it up equally

	*Bottom Quartile
	rdrobust sconservative_policy running_dst_2020 if education_4==1, all vce(cluster running_dst_2020)   // Bottom Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Bottom Quartile, DV, sconservative_policy) replace
	
	*Second Quartile
	rdrobust sconservative_policy running_dst_2020 if education_4==2, all vce(cluster running_dst_2020)   // Second Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Second Quartile, DV, sconservative_policy) append
	
	*Third Quartile
	rdrobust sconservative_policy running_dst_2020 ifeducation_4==3, all vce(cluster running_dst_2020)   // Third Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Third Quartile, DV, sconservative_policy) append
	
	*Top Quartile
	rdrobust sconservative_policy running_dst_2020 if education_4==4, all vce(cluster running_dst_2020)   // Top Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Top Quartile, DV, sconservative_policy) append
	
tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6  

foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	*Bottom Quartile
	rdrobust s`var' running_dst_2020 if education_4==1, all vce(cluster running_dst_2020)   // Bottom Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Bottom Quartile, DV, s`var') append
	
	*Second Quartile
	rdrobust s`var' running_dst_2020 if education_4==2, all vce(cluster running_dst_2020)   // Second Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Second Quartile, DV, s`var') append
	
	*Third Quartile
	rdrobust s`var' running_dst_2020 ifeducation_4==3, all vce(cluster running_dst_2020)   // Third Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Third Quartile, DV, s`var') append
	
	*Top Quartile
	rdrobust s`var' running_dst_2020 if education_4==4, all vce(cluster running_dst_2020)   // Top Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Top Quartile, DV, s`var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {

	*Bottom Quartile
	rdrobust `var' running_dst_2020 if education_4==1, all vce(cluster running_dst_2020)   // Bottom Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Bottom Quartile, DV, `var') append
	
	*Second Quartile
	rdrobust `var' running_dst_2020 if education_4==2, all vce(cluster running_dst_2020)   // Second Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Second Quartile, DV, `var') append
	
	*Third Quartile
	rdrobust `var' running_dst_2020 ifeducation_4==3, all vce(cluster running_dst_2020)   // Third Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Third Quartile, DV, `var') append
	
	*Top Quartile
	rdrobust `var' running_dst_2020 if education_4==4, all vce(cluster running_dst_2020)   // Top Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", detail(all) addlabel(Group, Top Quartile, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_education.dta", clear

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Second Quartile"
tab equivalence_cohen_small if Group=="Bottom Quartile"
tab equivalence_cohen_small if Group=="Third Quartile"
tab equivalence_cohen_small if Group=="Top Quartile"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

encode Group, gen(Group_num)

set seed 6809876

bs, reps(100): regress coef ib4.Group_num if prob==1, r
bs, reps(100):regress t ib4.Group_num if prob==1, r

bs, reps(100):regress coef ib4.Group_num if prob==0, r
bs, reps(100):regress t ib4.Group_num if prob==0, r


twoway (kdensity coef if Group_num==1 & probability==0, lcol(orange)) ///
(kdensity coef if Group_num==2 & probability==0, lcol(purple)) ///
(kdensity coef if Group_num==3 & probability==0, lcol(green)) ///
(kdensity coef if Group_num==4 & probability==0, lcol(maroon))

gr_edit .legend.plotregion1.label[1].text = {}
gr_edit .legend.plotregion1.label[1].text.Arrpush Bottom Quartile
gr_edit .legend.plotregion1.label[2].text = {}
gr_edit .legend.plotregion1.label[2].text.Arrpush Second Quartile
gr_edit .legend.plotregion1.label[3].text = {}
gr_edit .legend.plotregion1.label[3].text.Arrpush Third Quartile
gr_edit .legend.plotregion1.label[4].text = {}
gr_edit .legend.plotregion1.label[4].text.Arrpush Top Quartile
gr_edit .xaxis1.reset_rule -0.2 0.2 0.1 , tickset(major) ruletype(range) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effects (Standardized)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Density

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_education_quartiles.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_education_quartiles.pdf", as(pdf) name("Graph") replace




twoway (kdensity coef if Group_num==1 & probability==1, lcol(orange)) ///
(kdensity coef if Group_num==2 & probability==1, lcol(purple)) ///
(kdensity coef if Group_num==3 & probability==1, lcol(green)) ///
(kdensity coef if Group_num==4 & probability==1, lcol(maroon))

gr_edit .legend.plotregion1.label[1].text = {}
gr_edit .legend.plotregion1.label[1].text.Arrpush Bottom Quartile
gr_edit .legend.plotregion1.label[2].text = {}
gr_edit .legend.plotregion1.label[2].text.Arrpush Second Quartile
gr_edit .legend.plotregion1.label[3].text = {}
gr_edit .legend.plotregion1.label[3].text.Arrpush Third Quartile
gr_edit .legend.plotregion1.label[4].text = {}
gr_edit .legend.plotregion1.label[4].text.Arrpush Top Quartile
gr_edit .xaxis1.reset_rule -0.1 0.1 0.05 , tickset(major) ruletype(range) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effects (Standardized)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Density

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_education_quartiles_probability.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_education_quartiles_probability.pdf", as(pdf) name("Graph") replace


********************************** BY INCOME


cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

xtile income_4=household_income, n(4) // breaking it up equally

	*Bottom Quartile
	rdrobust sconservative_policy running_dst_2020 if income_4==1, all vce(cluster running_dst_2020)   // Bottom Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Bottom Quartile, DV, sconservative_policy) replace
	
	*Second Quartile
	rdrobust sconservative_policy running_dst_2020 if income_4==2, all vce(cluster running_dst_2020)   // Second Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Second Quartile, DV, sconservative_policy) append
	
	*Third Quartile
	rdrobust sconservative_policy running_dst_2020 ifincome_4==3, all vce(cluster running_dst_2020)   // Third Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Third Quartile, DV, sconservative_policy) append
	
	*Top Quartile
	rdrobust sconservative_policy running_dst_2020 if income_4==4, all vce(cluster running_dst_2020)   // Top Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Top Quartile, DV, sconservative_policy) append
	
	
foreach	var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	*Bottom Quartile
	rdrobust s`var' running_dst_2020 if income_4==1, all vce(cluster running_dst_2020)   // Bottom Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Bottom Quartile, DV, s`var') append
	
	*Second Quartile
	rdrobust s`var' running_dst_2020 if income_4==2, all vce(cluster running_dst_2020)   // Second Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Second Quartile, DV, s`var') append
	
	*Third Quartile
	rdrobust s`var' running_dst_2020 ifincome_4==3, all vce(cluster running_dst_2020)   // Third Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Third Quartile, DV, s`var') append
	
	*Top Quartile
	rdrobust s`var' running_dst_2020 if income_4==4, all vce(cluster running_dst_2020)   // Top Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Top Quartile, DV, s`var') append
	
	
}

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {

	*Bottom Quartile
	rdrobust `var' running_dst_2020 if income_4==1, all vce(cluster running_dst_2020)   // Bottom Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Bottom Quartile, DV, `var') append
	
	*Second Quartile
	rdrobust `var' running_dst_2020 if income_4==2, all vce(cluster running_dst_2020)   // Second Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Second Quartile, DV, `var') append
	
	*Third Quartile
	rdrobust `var' running_dst_2020 ifincome_4==3, all vce(cluster running_dst_2020)   // Third Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Third Quartile, DV, `var') append
	
	*Top Quartile
	rdrobust `var' running_dst_2020 if income_4==4, all vce(cluster running_dst_2020)   // Top Quartile
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", detail(all) addlabel(Group, Top Quartile, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_by_income.dta", clear

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Second Quartile"
tab equivalence_cohen_small if Group=="Bottom Quartile"
tab equivalence_cohen_small if Group=="Third Quartile"
tab equivalence_cohen_small if Group=="Top Quartile"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

encode Group, gen(Group_num)

set seed 6809876

bs, reps(100): regress coef ib4.Group_num if prob==1, r
bs, reps(100):regress t ib4.Group_num if prob==1, r

bs, reps(100):regress coef ib4.Group_num if prob==0, r
bs, reps(100):regress t ib4.Group_num if prob==0, r

twoway (kdensity coef if Group_num==1 & probability==0, lcol(orange)) ///
(kdensity coef if Group_num==2 & probability==0, lcol(purple)) ///
(kdensity coef if Group_num==3 & probability==0, lcol(green)) ///
(kdensity coef if Group_num==4 & probability==0, lcol(maroon))

gr_edit .legend.plotregion1.label[1].text = {}
gr_edit .legend.plotregion1.label[1].text.Arrpush Bottom Quartile
gr_edit .legend.plotregion1.label[2].text = {}
gr_edit .legend.plotregion1.label[2].text.Arrpush Second Quartile
gr_edit .legend.plotregion1.label[3].text = {}
gr_edit .legend.plotregion1.label[3].text.Arrpush Third Quartile
gr_edit .legend.plotregion1.label[4].text = {}
gr_edit .legend.plotregion1.label[4].text.Arrpush Top Quartile
gr_edit .xaxis1.reset_rule -0.2 0.2 0.1 , tickset(major) ruletype(range) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effects (Standardized)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Density

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_income_quartiles.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_income_quartiles.pdf", as(pdf) name("Graph") replace




twoway (kdensity coef if Group_num==1 & probability==1, lcol(orange)) ///
(kdensity coef if Group_num==2 & probability==1, lcol(purple)) ///
(kdensity coef if Group_num==3 & probability==1, lcol(green)) ///
(kdensity coef if Group_num==4 & probability==1, lcol(maroon))

gr_edit .legend.plotregion1.label[1].text = {}
gr_edit .legend.plotregion1.label[1].text.Arrpush Bottom Quartile
gr_edit .legend.plotregion1.label[2].text = {}
gr_edit .legend.plotregion1.label[2].text.Arrpush Second Quartile
gr_edit .legend.plotregion1.label[3].text = {}
gr_edit .legend.plotregion1.label[3].text.Arrpush Third Quartile
gr_edit .legend.plotregion1.label[4].text = {}
gr_edit .legend.plotregion1.label[4].text.Arrpush Top Quartile
gr_edit .xaxis1.reset_rule -0.1 0.1 0.05 , tickset(major) ruletype(range) 
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effects (Standardized)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Density

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_income_quartiles_probability.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_income_quartiles_probability.pdf", as(pdf) name("Graph") replace











*************************** SPRING CUTOFF - ALL, JUST 2020 ********************************************
cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

use "nsALLCLEAN.dta", clear

sort start_date

	rdrobust sconservative_policy running_dst_2020 if start_day_year=="2020", all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group,  all, DV, sconservative_policy) replace

	*Democrats
	rdrobust sconservative_policy running_dst_2020 if pid3==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Democrats, DV, sconservative_policy) append
	
	*Republicans
	rdrobust sconservative_policy running_dst_2020 if pid3==2 & start_day_year=="2020", all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Republicans, DV, sconservative_policy) append
	
	*Independents
	rdrobust sconservative_policy running_dst_2020 if pid3==3 & start_day_year=="2020", all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Independents, DV, sconservative_policy) append
	
	*Other
	rdrobust sconservative_policy running_dst_2020 if pid3==4 & start_day_year=="2020", all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Other Party, DV, sconservative_policy) append
	
	*White
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, White, DV, sconservative_policy) append
	
	*Black
	rdrobust sconservative_policy running_dst_2020 if race_ethnicity==2 &  start_day_year=="2020", all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Black, DV, sconservative_policy) append
	
	*Asian
	rdrobust sconservative_policy running_dst_2020 if aapi_race==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Asian, DV, sconservative_policy) append
	
foreach var in conservatisim cand_favorability_trump cand_favorability_biden  group_favorability_democrats group_favorability_republicans /// political views
racial_resentment gender_resentment group_favorability_whites group_favorability_blacks group_favorability_latinos group_favorability_asians group_favorability_evangelicals group_favorability_socialists group_favorability_muslims group_favorability_labor_unions group_favorability_the_police group_favorability_undocumented group_favorability_lgbt group_favorability_white_men group_favorability_jews /// social views
{
	
	rdrobust s`var' running_dst_2020 if start_day_year=="2020", all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group,  all, DV, s`var') append

	*Democrats
	rdrobust s`var' running_dst_2020 if pid3==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Democrats, DV, s`var') append
	
	*Republicans
	rdrobust s`var' running_dst_2020 if pid3==2 & start_day_year=="2020", all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Republicans, DV, s`var') append
	
	*Independents
	rdrobust s`var' running_dst_2020 if pid3==3 & start_day_year=="2020", all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Independents, DV, s`var') append
	
	*Other
	rdrobust s`var' running_dst_2020 if pid3==4 & start_day_year=="2020", all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Other Party, DV, s`var') append
	
	*White
	rdrobust s`var' running_dst_2020 if race_ethnicity==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust s`var' running_dst_2020 if race_ethnicity==2 &  start_day_year=="2020", all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust s`var' running_dst_2020 if aapi_race==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
	
}




foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines {
	
	rdrobust `var' running_dst_2020 if start_day_year=="2020", all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group,  all, DV, `var') append

	*Democrats
	rdrobust `var' running_dst_2020 if pid3==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Democrats, DV, `var') append
	
	*Republicans
	rdrobust `var' running_dst_2020 if pid3==2 & start_day_year=="2020", all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Republicans, DV, `var') append
	
	*Independents
	rdrobust `var' running_dst_2020 if pid3==3 & start_day_year=="2020", all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Independents, DV, `var') append
	
	*Other
	rdrobust `var' running_dst_2020 if pid3==4 & start_day_year=="2020", all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Other Party, DV, `var') append
	
	*White
	rdrobust `var' running_dst_2020 if race_ethnicity==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, White, DV, `var') append
	
	*Black
	rdrobust `var' running_dst_2020 if race_ethnicity==2 &  start_day_year=="2020", all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Black, DV, `var') append
	
	*Asian
	rdrobust `var' running_dst_2020 if aapi_race==1 & start_day_year=="2020", all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", detail(all) addlabel(Group, Asian, DV, `var') append
	
}

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020.dta", clear

sum coef, d
sum h_l, d
sum b_l, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(DV, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small

tab equivalence_cohen_small if Group=="All"
tab equivalence_cohen_small if Group=="Republicans"
tab equivalence_cohen_small if Group=="Democrats"
tab equivalence_cohen_small if Group=="Independents"
tab equivalence_cohen_small if Group=="Other Party"
tab equivalence_cohen_small if Group=="Black"
tab equivalence_cohen_small if Group=="White"
tab equivalence_cohen_small if Group=="Asian"

tab sig equivalence_cohen_small, cell

tab DV if sig==1 // mostly conservative policy views the scale

sum coef if DV=="sconservative_policy"

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020_clean.dta", version(12) replace

hist coef if prob==0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.3 0.3 0.1 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist_just_2020.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist_just_2020.pdf", as(pdf) name("Graph") replace

hist coef if prob==1, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy
gr_edit .xaxis1.reset_rule -0.3 0.3 0.1 , tickset(major) ruletype(range) 

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist_just_2020.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist_just_2020.pdf", as(pdf) name("Graph") replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020_clean.dta", clear

replace DV="Gender Resentment" if DV=="sgender_resentment"
replace DV="Racial Resentment" if DV=="sracial_resentment"
replace DV="Pres Challenger" if DV=="scand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="scand_favorability_trump"
replace DV="Whites" if DV=="sgroup_favorability_whites"
replace DV="Blacks" if DV=="sgroup_favorability_blacks"
replace DV="Latinos" if DV=="sgroup_favorability_latinos"
replace DV="Asians" if DV=="sgroup_favorability_asians"
replace DV="Evangelicals" if DV=="sgroup_favorability_evangelicals"
replace DV="Socialists" if DV=="sgroup_favorability_socialists"
replace DV="Muslims" if DV=="sgroup_favorability_muslims"
replace DV="Unions" if DV=="sgroup_favorability_labor_unions"
replace DV="Police" if DV=="sgroup_favorability_the_police"
replace DV="Undocumented" if DV=="sgroup_favorability_undocumented"
replace DV="LGBT" if DV=="sgroup_favorability_lgbt"
replace DV="White Men" if DV=="sgroup_favorability_white_men"
replace DV="Jews" if DV=="sgroup_favorability_jews"
replace DV="Democrats" if DV=="sgroup_favorability_democrats"
replace DV="Republicans" if DV=="sgroup_favorability_republicans"

replace DV="Gender Resentment" if DV=="gender_resentment"
replace DV="Racial Resentment" if DV=="racial_resentment"
replace DV="Pres Challenger" if DV=="cand_favorability_biden"
replace DV="Pres Incumbent"  if DV=="cand_favorability_trump"
replace DV="Whites" if DV=="group_favorability_whites"
replace DV="Blacks" if DV=="group_favorability_blacks"
replace DV="Latinos" if DV=="group_favorability_latinos"
replace DV="Asians" if DV=="group_favorability_asians"
replace DV="Evangelicals" if DV=="group_favorability_evangelicals"
replace DV="Socialists" if DV=="group_favorability_socialists"
replace DV="Muslims" if DV=="group_favorability_muslims"
replace DV="Unions" if DV=="group_favorability_labor_unions"
replace DV="Police" if DV=="group_favorability_the_police"
replace DV="Undocumented" if DV=="group_favorability_undocumented"
replace DV="LGBT" if DV=="group_favorability_lgbt"
replace DV="White Men" if DV=="group_favorability_white_men"
replace DV="Jews" if DV=="group_favorability_jews"
replace DV="Democrats" if DV=="group_favorability_democrats"
replace DV="Republicans" if DV=="group_favorability_republicans"

replace DV="Limit Magazines" if DV=="c_limit_magazines"
replace DV="Ban ARs" if DV=="c_ban_assault_rifles"
replace DV="Ban Guns" if DV=="c_ban_guns"
replace DV="Deport Immigrants" if DV=="c_deportation"
replace DV="Citizenship Dreamers" if DV=="c_dreamers"
replace DV="Path Citizenship" if DV=="c_path_to_citizenship"
replace DV="Health Subsidies" if DV=="c_health_subsidies"
replace DV="Public Option" if DV=="c_public_option"
replace DV="Gov. Insurance" if DV=="c_gov_insurance"
replace DV="Late Abortion" if DV=="c_late_term_abortion"
replace DV="Abortion Never" if DV=="c_abortion_never"
replace DV="College Debt" if DV=="c_college"
replace DV="Raise Tax Upper" if DV=="c_raise_upper_tax"
replace DV="Eliminate Estate Tax" if DV=="c_estate_tax"
replace DV="Background Checks" if DV=="c_guns_bg"
replace DV="Cap Carbon" if DV=="c_cap_carbon"
replace DV="Build Wall" if DV=="c_wall"

drop if DV=="sconservatisim" | DV=="sconservative_policy" // just mentioned

keep DV Group sig equivalence_cohen_small equivalence_10

gen Group_num=1 if Group=="All"
replace Group_num=2 if Group=="Republicans"
replace Group_num=3 if Group=="Democrats"
replace Group_num=4 if Group=="Independents"
replace Group_num=5 if Group=="Other Party"
replace Group_num=6 if Group=="White"
replace Group_num=7 if Group=="Black"
replace Group_num=8 if Group=="Asian"

gen DV_num=1 if   DV== "Gender Resentment" 
replace DV_num=2 if    DV== "Racial Resentment" 
replace DV_num=3 if    DV== "Pres Challenger" 
replace DV_num=4 if    DV== "Pres Incumbent"  
replace DV_num=5 if    DV== "Whites" 
replace DV_num=6 if    DV== "Blacks" 
replace DV_num=7 if    DV== "Latinos" 
replace DV_num=8 if    DV== "Asians" 
replace DV_num=9 if    DV== "Evangelicals" 
replace DV_num=10 if    DV== "Socialists" 
replace DV_num=11 if    DV== "Muslims" 
replace DV_num=12 if    DV== "Unions" 
replace DV_num=13 if    DV== "Police" 
replace DV_num=14 if    DV== "Undocumented" 
replace DV_num=15 if    DV== "LGBT" 
replace DV_num=16 if    DV== "White Men" 
replace DV_num=17 if    DV== "Jews" 
replace DV_num=18 if    DV== "Democrats" 
replace DV_num=19 if    DV== "Republicans" 
replace DV_num=20 if    DV== "Limit Magazines" 
replace DV_num=21 if    DV== "Ban ARs" 
replace DV_num=22 if    DV== "Ban Guns" 
replace DV_num=23 if    DV== "Deport Immigrants" 
replace DV_num=24 if    DV== "Citizenship Dreamers" 
replace DV_num=25 if    DV== "Path Citizenship" 
replace DV_num=26 if    DV== "Health Subsidies" 
replace DV_num=27 if    DV== "Public Option" 
replace DV_num=28 if    DV== "Gov. Insurance" 
replace DV_num=29 if    DV== "Late Abortion" 
replace DV_num=30 if    DV== "Abortion Never" 
replace DV_num=31 if    DV== "College Debt" 
replace DV_num=32 if    DV== "Raise Tax Upper" 
replace DV_num=33 if    DV== "Eliminate Estate Tax" 
replace DV_num=34 if    DV== "Background Checks" 
replace DV_num=35 if    DV== "Cap Carbon" 
replace DV_num=36 if    DV== "Build Wall"

drop if DV=="conservatisim"

tab equivalence_cohen_small 
tab equivalence_10 

tab sig equivalence_cohen_small, cell // 1.04% are significant and can't rule out Cohen small effects/20% probability 
tab sig equivalence_10, cell // 3.47% are significant and can't rule out Cohen small effects/10% probability 

*For Outcomes: 1 = "Gender Resentment"; 2 = "Racial Resentment"; 3 = "Pres Challenger"; 4 = "Pres Incumbent"; 5 = "Whites"; 6 = "Blacks";7 = "Latinos"; 8 = "Asians"; 9 = "Evangelicals"; 10 = "Socialists"; 11 = "Muslims"; 12 = "Unions"; 13 = "Police"; 14 = "Undocumented"; 15 = "LGBT"; 16 = "White Men"; 17 = "Jews"; 18 = "Democrats"; 19 = "Republicans"; 20 = "Limit Magazines"; 21 = "Ban ARs"; 22 = "Ban Guns"; 23 = "Deport Immigrants"; 24 = "Citizenship Dreamers"; 25 = "Path Citizenship"; 26 = "Health Subsidies"; 27 = "Public Option"; 28 = "Gov. Insurance"; 29 = "Late Abortion"; 30 = "Abortion Never"; 31 = "College Debt"; 32 = "Raise Tax Upper"; 33 = "Eliminate Estate Tax"; 34 = "Background Checks"; 35 = "Cap Carbon"; 36 = "Build Wall"

*For Subgroups 1 = "All"; 2 = "Republicans"; 3 = "Democrats"; 4 = "Independents"; 5 = "Other Party"; 6 = "Whites"; 7 = "Blacks"; 8 = "Asians"

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/all_dvs_spring_just_2020_clean.dta", replace version(12)

********************************* EVENT STUDY

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" // change directory here

foreach var in c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sconservative_policy sconservatisim scand_favorability_trump scand_favorability_biden  sgroup_favorability_democrats sgroup_favorability_republicans sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews {
	
use "nsALLCLEAN.dta", clear

sort start_date

keep if running_dst_2020>-8 & running_dst_2020<8

tab running_dst_2020, gen(running_dst_2020_num_)

encode state, gen(state_num)

gen month_num=2 if start_day_month=="feb"
replace month_num=3 if start_day_month=="mar"
replace month_num=4 if start_day_month=="apr"


sum age pid3 employment foreign_born language religion  gender census_region race_ethnicity household_income education married

tab pid3, gen(party_)

gen unemployed=1 if employment==4
replace unemployed=0 if employment~=4 & employment~=.

recode foreign_born (1=0) (2=1)

gen english_only=1 if language==3
replace english_only=0 if language==1 | language==2

tab religion, gen(religion_num_)

replace gender=0 if gender==2
rename gender female

tab census_region, gen(census_region_num_)

tab race_ethnicity, gen(race_ethnicity_num_)

gen over_60 =1 if age>60 & age~=. // just so all vars are 0/1, makes no difference
replace over_60=0 if age<60

gen over_median_income=1 if household_income>8 & household_income~=.
replace over_median_income=0 if household_income<=8 

gen over_median_ed=1 if education>6 & education~=.
replace over_median_ed=0 if education<=6   

reghdfe  `var'  running_dst_2020_num_1 running_dst_2020_num_2 running_dst_2020_num_3 running_dst_2020_num_4 running_dst_2020_num_5 running_dst_2020_num_6 /// pre treatment
 running_dst_2020_num_8 running_dst_2020_num_9 running_dst_2020_num_10 running_dst_2020_num_11 running_dst_2020_num_12 running_dst_2020_num_13 running_dst_2020_num_14 running_dst_2020_num_15, /// post treatments
absorb(state_num party_1 party_2 party_3 party_4 unemployed foreign_born english_only female religion_num_1 religion_num_2 religion_num_3 religion_num_4 religion_num_5 religion_num_6 religion_num_7 religion_num_8 religion_num_9 religion_num_10 religion_num_11 religion_num_12 religion_num_13 census_region_num_1 census_region_num_2 census_region_num_3 census_region_num_4 race_ethnicity_num_1 race_ethnicity_num_2 race_ethnicity_num_3 race_ethnicity_num_4 race_ethnicity_num_5 race_ethnicity_num_6 race_ethnicity_num_7 race_ethnicity_num_8 race_ethnicity_num_9 race_ethnicity_num_10 race_ethnicity_num_11 race_ethnicity_num_12 race_ethnicity_num_13 race_ethnicity_num_14 race_ethnicity_num_15 over_median_income over_median_ed) 

regsave running_dst_2020_num_1 running_dst_2020_num_2 running_dst_2020_num_3 running_dst_2020_num_4 running_dst_2020_num_5 running_dst_2020_num_6 running_dst_2020_num_8 running_dst_2020_num_9 running_dst_2020_num_10 running_dst_2020_num_11 running_dst_2020_num_12 running_dst_2020_num_13 running_dst_2020_num_14 running_dst_2020_num_15 using  "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_`var'.dta", detail(all) replace

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_`var'.dta", clear

gen center_day=.
order center_day 

replace center_day = 0 in 7
replace center_day = 1 in 8
replace center_day = 2 in 9
replace center_day = 3 in 10
replace center_day = 4 in 11
replace center_day = 5 in 12
replace center_day = 6 in 13
replace center_day = 7 in 14
replace center_day = -2 in 6
replace center_day = -3 in 5
replace center_day = -4 in 4
replace center_day = -5 in 3
replace center_day = -6 in 2
replace center_day = -7 in 1

set obs `=_N+1'
replace center_day = -1 in 15 // baseline day
replace coef = 0 in 15
replace stderr = 0 in 15

drop indepvars  cmdline  extended_absv~s absvars     

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_`var'_clean.dta", version(12) replace

}


cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/" // change directory here

**** POST MODEL ANALYSIS
use "event_study_sgroup_favorability_jews_clean.dta", clear

foreach var in event_study_sgroup_favorability_white_men_clean event_study_sgroup_favorability_lgbt_clean event_study_sgroup_favorability_undocumented_clean event_study_sgroup_favorability_the_police_clean event_study_sgroup_favorability_labor_unions_clean event_study_sgroup_favorability_muslims_clean event_study_sgroup_favorability_socialists_clean event_study_sgroup_favorability_evangelicals_clean event_study_sgroup_favorability_asians_clean event_study_sgroup_favorability_latinos_clean event_study_sgroup_favorability_blacks_clean event_study_sgroup_favorability_whites_clean event_study_sgender_resentment_clean event_study_sracial_resentment_clean event_study_sgroup_favorability_republicans_clean event_study_sgroup_favorability_democrats_clean event_study_scand_favorability_biden_clean event_study_scand_favorability_trump_clean event_study_sconservatisim_clean event_study_sconservative_policy_clean event_study_c_limit_magazines_clean event_study_c_ban_assault_rifles_clean event_study_c_ban_guns_clean event_study_c_deportation_clean event_study_c_dreamers_clean event_study_c_path_to_citizenship_clean event_study_c_health_subsidies_clean event_study_c_public_option_clean event_study_c_gov_insurance_clean event_study_c_late_term_abortion_clean event_study_c_abortion_never_clean event_study_c_college_clean event_study_c_raise_upper_tax_clean event_study_c_estate_tax_clean event_study_c_guns_bg_clean event_study_c_cap_carbon_clean event_study_c_wall_clean {
	
	
	append using "`var'.dta"
}

drop if stderr==0

sum coef, d

gen t=coef/stderr
gen sig=1 if t>1.96 | t<-1.96
replace sig=0 if sig==.
tab sig if center_day>=0

gen abs_coef=abs(coef)
sort abs_coef

sum abs_coef, d

gen DV_standardize=substr(depvar, 1, 2)

gen lb95=coef-1.96*stderr
gen ub95=coef+1.96*stderr

gen equivalence_cohen_small=1 if lb95>-0.2 & ub95<0.2
replace equivalence_cohen_small=0 if lb95<=-0.2 | ub95>=0.2

gen equivalence_10=1 if lb95>-0.1 & ub95<0.1
replace equivalence_10=0 if lb95<=-0.1 | ub95>=0.1

tab equivalence_cohen_small if center_day>=0

tab sig equivalence_cohen_small if center_day>=0 & prob==0, cell
tab sig equivalence_10 if center_day>=0 & prob==1, cell

tab depvar if sig==1 // mostly conservative policy views the scale

gen probability=1 if DV_standardize=="c_"
replace probability=0 if  DV_standardize~="c_"


hist coef if prob==0 & center_day>=0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Standardized)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist_post_event_study.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_standardized_dist_post_event_study.pdf", as(pdf) name("Graph") replace

hist coef if prob==1 & center_day>=0, frequency kdensity normal
gr_edit .plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
gr_edit .xaxis1.title.text = {}
gr_edit .xaxis1.title.text.Arrpush Effect Estimate (Probability)
gr_edit .xaxis1.plotregion._xylines_new = 1
gr_edit .xaxis1.plotregion._xylines_rec = 1
gr_edit .plotregion1.plot1.style.editstyle area(shadestyle(intensity(inten60))) editcopy
gr_edit .plotregion1.plot1.style.editstyle area(linestyle(color(none))) editcopy
gr_edit .plotregion1.plot3.style.editstyle line(color(reddish)) editcopy

graph save "Graph" "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist_post_event_study.gph", replace
graph export "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/spring_probability_dist_post_event_study.pdf", as(pdf) name("Graph") replace


*Event Study Tables
*16a
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sconservative_policy_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS16a.tex, replace

*16b

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sconservatisim_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS16b.tex, replace

*16c
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_scand_favorability_biden_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS16c.tex, replace

*16d	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_scand_favorability_trump_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS16d.tex, replace

*17a
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_republicans_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS17a.tex, replace

*17b

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_democrats_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS17b.tex, replace

*17c
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgender_resentment_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS17c.tex, replace

*17d	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sracial_resentment_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS17d.tex, replace


*18a
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_jews_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS18a.tex, replace

*18b

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_evangelicals_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS18b.tex, replace

*18c
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_muslims_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS18c.tex, replace

*18d	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_socialists_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS18d.tex, replace


*19a
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_whites_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS19a.tex, replace

*19b

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_latinos_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS19b.tex, replace

*19c
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_blacks_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS19c.tex, replace

*19d	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_asians_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS19d.tex, replace


*20a
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_labor_unions_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS20a.tex, replace

*20b

use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_the_police_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS20b.tex, replace

*20c
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_undocumented_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS20c.tex, replace

*20d	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/event_study_sgroup_favorability_lgbt_clean.dta", clear

keep center_day coef stderr N

foreach var in coef stderr {
	
	replace `var'=round(`var', 0.01)
}

texsave * using figureS20d.tex, replace



event_study_sgroup_favorability_white_men_clean event_study_sgroup_favorability_lgbt_clean event_study_sgroup_favorability_undocumented_clean event_study_sgroup_favorability_the_police_clean event_study_sgroup_favorability_labor_unions_clean event_study_sgroup_favorability_muslims_clean event_study_sgroup_favorability_socialists_clean event_study_sgroup_favorability_evangelicals_clean event_study_sgroup_favorability_asians_clean event_study_sgroup_favorability_latinos_clean event_study_sgroup_favorability_blacks_clean event_study_sgroup_favorability_whites_clean event_study_sgender_resentment_clean event_study_sracial_resentment_clean event_study_sgroup_favorability_republicans_clean event_study_sgroup_favorability_democrats_clean event_study_scand_favorability_biden_clean event_study_scand_favorability_trump_clean event_study_sconservatisim_clean event_study_sconservative_policy_clean event_study_c_limit_magazines_clean event_study_c_ban_assault_rifles_clean event_study_c_ban_guns_clean event_study_c_deportation_clean event_study_c_dreamers_clean event_study_c_path_to_citizenship_clean event_study_c_health_subsidies_clean event_study_c_public_option_clean event_study_c_gov_insurance_clean event_study_c_late_term_abortion_clean event_study_c_abortion_never_clean event_study_c_college_clean event_study_c_raise_upper_tax_clean event_study_c_estate_tax_clean event_study_c_guns_bg_clean event_study_c_cap_carbon_clean event_study_c_wall_clean 	
	
	
	
******************************************* FACTOR WEIGHTED

cd "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/alldtas/" 

use "nsALLCLEAN.dta", clear

factor c_wall c_cap_carbon c_guns_bg c_estate_tax c_raise_upper_tax c_college c_abortion_never  c_late_term_abortion c_gov_insurance c_public_option c_health_subsidies c_path_to_citizenship c_dreamers c_deportation c_ban_guns c_ban_assault_rifles c_limit_magazines sconservatisim scand_favorability_trump scand_favorability_biden sgroup_favorability_democrats sgroup_favorability_republicans

predict politics
egen Spolitics=std(politics)

factor sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews

predict social
egen Ssocial=std(social)

egen Sdiscrimination_mean=rowmean(sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews)

egen Sdiscrimination_mean=rowmean(sracial_resentment sgender_resentment sgroup_favorability_whites sgroup_favorability_blacks sgroup_favorability_latinos sgroup_favorability_asians sgroup_favorability_evangelicals sgroup_favorability_socialists sgroup_favorability_muslims sgroup_favorability_labor_unions sgroup_favorability_the_police sgroup_favorability_undocumented sgroup_favorability_lgbt sgroup_favorability_white_men sgroup_favorability_jews)

egen Spolarization_mean=rowmean(sconservatisim scand_favorability_trump scand_favorability_biden sgroup_favorability_democrats sgroup_favorability_republicans)


******* POLITICS

	rdrobust Spolitics running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, All, DV, Politics) replace

	*Democrats
	rdrobust Spolitics running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Democrats, DV, Politics) append
	
	*Republicans
	rdrobust Spolitics running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Republicans, DV, Politics) append
	
	*Independents
	rdrobust Spolitics running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Independents, DV, Politics) append
	
	*Other
	rdrobust Spolitics running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Other Party, DV, Politics) append
	
	*White
	rdrobust Spolitics running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, White, DV, Politics) append
	
	*Black
	rdrobust Spolitics running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Black, DV, Politics) append
	
	*Asian
	rdrobust Spolitics running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Asian, DV, Politics) append

******** SOCIAL 


	rdrobust Ssocial running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, All, DV, social) append

	*Democrats
	rdrobust Ssocial running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Democrats, DV, social) append
	
	*Republicans
	rdrobust Ssocial running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Republicans, DV, social) append
	
	*Independents
	rdrobust Ssocial running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Independents, DV, social) append
	
	*Other
	rdrobust Ssocial running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Other Party, DV, social) append
	
	*White
	rdrobust Ssocial running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, White, DV, social) append
	
	*Black
	rdrobust Ssocial running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Black, DV, social) append
	
	*Asian
	rdrobust Ssocial running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", detail(all) addlabel(Group, Asian, DV, social) append
	
*cleaning + analysis	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions.dta", clear

replace DV="Social (Higher=More Animus Towards Minority Groups)" if DV=="social"
replace DV="Politics (Higher=More Conservative)" if DV=="Politics"

capture drop num
gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_clean.dta", version(12) replace


*23	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_clean.dta", clear

keep Group DV coef stderr N h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb

foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order Group DV

texsave * using figureS23.tex, replace


******************************* MEAN SCALES


******* POLITICS

	rdrobust Spolarization_mean running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, All, DV, Politics) replace

	*Democrats
	rdrobust Spolarization_mean running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Democrats, DV, Politics) append
	
	*Republicans
	rdrobust Spolarization_mean running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Republicans, DV, Politics) append
	
	*Independents
	rdrobust Spolarization_mean running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Independents, DV, Politics) append
	
	*Other
	rdrobust Spolarization_mean running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Other Party, DV, Politics) append
	
	*White
	rdrobust Spolarization_mean running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, White, DV, Politics) append
	
	*Black
	rdrobust Spolarization_mean running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Black, DV, Politics) append
	
	*Asian
	rdrobust Spolarization_mean running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Asian, DV, Politics) append

******** SOCIAL 


	rdrobust Sdiscrimination_mean running_dst_2020, all vce(cluster running_dst_2020) // all
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, All, DV, social) append

	*Democrats
	rdrobust Sdiscrimination_mean running_dst_2020 if pid3==1, all vce(cluster running_dst_2020) // Democrats
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Democrats, DV, social) append
	
	*Republicans
	rdrobust Sdiscrimination_mean running_dst_2020 if pid3==2, all vce(cluster running_dst_2020) // Republicans
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Republicans, DV, social) append
	
	*Independents
	rdrobust Sdiscrimination_mean running_dst_2020 if pid3==3, all vce(cluster running_dst_2020) // Independents
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Independents, DV, social) append
	
	*Other
	rdrobust Sdiscrimination_mean running_dst_2020 if pid3==4, all vce(cluster running_dst_2020) // Other party
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Other Party, DV, social) append
	
	*White
	rdrobust Sdiscrimination_mean running_dst_2020 if race_ethnicity==1, all vce(cluster running_dst_2020) // White
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, White, DV, social) append
	
	*Black
	rdrobust Sdiscrimination_mean running_dst_2020 if race_ethnicity==2, all vce(cluster running_dst_2020) // Black
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Black, DV, social) append
	
	*Asian
	rdrobust Sdiscrimination_mean running_dst_2020 if aapi_race==1, all vce(cluster running_dst_2020) // Asian
	regsave Robust using "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", detail(all) addlabel(Group, Asian, DV, social) append
	
*cleaning + analysis	
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales.dta", clear

replace DV="Social (Higher=More Animus Towards Minority Groups)" if DV=="social"
replace DV="Politics (Higher=More Conservative)" if DV=="Politics"

capture drop num
gen num=-_n

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

saveold "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales_clean.dta", version(12) replace

*24
use "/Users/johnholbein/Dropbox (Batten School @ UVA)/Work/Nationscape Data/Sleep/findings/two_dimensions_mean_scales_clean.dta", clear

keep Group DV coef stderr N h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb

foreach var in coef stderr h_l h_r b_l b_r pv_rb ci_r_rb ci_l_rb {
	
	replace `var'=round(`var', 0.01)
}

order Group DV

texsave * using figureS24.tex, replace
